fix: Void functions return null instead of empty body (#1795)

* Change empty body reponse to null for scalar functions returning void or null values

* Add test for functions returning an integer with null value

Co-authored-by: Laurence Isla <lau.isla.c@gmail.com>
This commit is contained in:
laurenceisla
2021-04-08 01:45:13 +02:00
committed by GitHub
co-authored by Laurence Isla
parent 9c79a4174c
commit 7f11c1a991
3 changed files with 15 additions and 4 deletions
+1 -1
View File
@@ -98,7 +98,7 @@ asJsonF returnsScalar
asJsonSingleF :: Bool -> SqlFragment --TODO! unsafe when the query actually returns multiple rows, used only on inserting and returning single element
asJsonSingleF returnsScalar
| returnsScalar = "coalesce(string_agg(to_json(_postgrest_t.pgrst_scalar)::text, ','), '')::character varying"
| returnsScalar = "coalesce(string_agg(to_json(_postgrest_t.pgrst_scalar)::text, ','), 'null')::character varying"
| otherwise = "coalesce(string_agg(to_json(_postgrest_t)::text, ','), '')::character varying"
asBinaryF :: FieldName -> SqlFragment