fix: error when a function returns RECORD or SETOF RECORD

This commit is contained in:
Laurence Isla
2023-08-03 20:09:55 -05:00
committed by GitHub
parent 0fce7ca361
commit aa53623aac
4 changed files with 40 additions and 1 deletions
+21
View File
@@ -475,6 +475,27 @@ spec actualPgVersion =
`shouldRespondWith`
[json|null|]
when (actualPgVersion >= pgVersion110) $ do
it "returns a record type" $ do
post "/rpc/returns_record"
""
`shouldRespondWith`
[json|{"id":1,"name":"Windows 7","client_id":1}|]
post "/rpc/returns_record_params"
[json|{"id":1, "name": "Windows%"}|]
`shouldRespondWith`
[json|{"id":1,"name":"Windows 7","client_id":1}|]
it "returns a setof record type" $ do
post "/rpc/returns_setof_record"
""
`shouldRespondWith`
[json|[{"id":1,"name":"Windows 7","client_id":1},{"id":2,"name":"Windows 10","client_id":1}]|]
post "/rpc/returns_setof_record_params"
[json|{"id":1,"name":"Windows%"}|]
`shouldRespondWith`
[json|[{"id":1,"name":"Windows 7","client_id":1},{"id":2,"name":"Windows 10","client_id":1}]|]
context "different types when overloaded" $ do
it "returns composite type" $
post "/rpc/ret_point_overloaded"
+16
View File
@@ -3352,3 +3352,19 @@ create or replace function bit_param_insert(bit_ bit(4), bit_arr bit(4)[])
returns void as $$
insert into bitchar_with_length(bit, bit_arr) values($1, $2);
$$ language sql;
create function returns_record() returns record as $$
select * from projects limit 1;
$$ language sql;
create function returns_record_params(id int, name text) returns record as $$
select * from projects p where p.id = $1 and p.name like $2;
$$ language sql;
create function returns_setof_record() returns setof record as $$
select * from projects limit 2;
$$ language sql;
create function returns_setof_record_params(id int, name text) returns setof record as $$
select * from projects p where p.id >= $1 and p.name like $2;
$$ language sql;