diff --git a/infra/migrations/022_round_float_overload.sql b/infra/migrations/022_round_float_overload.sql new file mode 100644 index 0000000..d1bd567 --- /dev/null +++ b/infra/migrations/022_round_float_overload.sql @@ -0,0 +1,8 @@ +-- Add a round(double precision, integer) overload so ad-hoc queries +-- using round(some_float, 2) work without explicit ::numeric casts. +-- PostgreSQL only provides round(numeric, integer) out of the box. + +CREATE OR REPLACE FUNCTION round(double precision, integer) +RETURNS numeric AS $$ + SELECT round($1::numeric, $2); +$$ LANGUAGE sql IMMUTABLE STRICT;