From f1e32e918619f941fea8b194949b4e7275378252 Mon Sep 17 00:00:00 2001 From: Celes Renata Date: Thu, 16 Apr 2026 07:10:23 +0000 Subject: [PATCH] fix: add round(double precision, integer) overload so ad-hoc queries work without ::numeric casts --- infra/migrations/022_round_float_overload.sql | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 infra/migrations/022_round_float_overload.sql 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;