-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incorrect behavior of header Prefer: params=single-object
on overloaded function
#1469
Comments
Hmm.. I cannot reproduce. I get: [{"test":{
"a": "a",
"b": "b"
}}] Consistently, on both 6.0.2 and master version. Even after Not saying the above output is right though, I think the top key |
This is the bug
The problem is that the type of return value is not determined correctly: When both functions are present in the database call second function returnsScalar is false, but must be true. |
Prefer: params=single-object
I can now reproduce. Here's a test case that could be put in our create type custom_type as (
a text
, b text
);
create or replace function get_custom_type(a text, b text) returns custom_type
as $_$
select row (a, b)::custom_type;
$_$ language sql;
create or replace function get_custom_type(json) returns json
as $_$
select $1;
$_$ language sql; When calling the latter function, we get: curl 'l:3000/rpc/get_custom_type' \
-H 'Content-Type: application/json' \
-H 'Prefer: params=single-object' \
-d '{
"a": "a",
"b": "b"
}'
[{"get_custom_type":{
"a": "a",
"b": "b"
}}] And when dropping the former function For now, the workaround would be having the json param function like: create or replace function get_custom_type(json) returns custom_type
as $_$
select * from json_populate_record(null::custom_type, $1)
$_$ language sql; This is kind of an edge case. As I think is not usual to change the return type of an overloaded function. Should definitely be corrected though. |
Prefer: params=single-object
Prefer: params=single-object
on overloaded function
Incorrect behavior of header
Prefer: params=single-object
We have got overridden function
send request with header
Prefer: params=single-object
returns incorrect response
after dropping first function
and repeat request i have got correct response
The text was updated successfully, but these errors were encountered: