Skip to content
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

Simple objects returned from functions are converted to strings #1930

Closed
mrussell16 opened this issue Aug 31, 2021 · 1 comment · Fixed by #1931
Closed

Simple objects returned from functions are converted to strings #1930

mrussell16 opened this issue Aug 31, 2021 · 1 comment · Fixed by #1931
Assignees
Labels

Comments

@mrussell16
Copy link

Environment

  • PostgreSQL version: postgres:11 (docker image)
  • PostgREST version: postgrest/postgrest:v8.0.0 (docker image)
  • Operating system: Ubuntu 20.04

Description of issue

The return type changed from version 7.0.1 to version 8.0.0 for functions that return simple object arrays. In version 7.0.1 this returns the object with its original keys, but in version 8.0.0 the objects are converted to strings.

Defining a test function with permissions for anonymous users to run:

CREATE FUNCTION public_api.test() RETURNS TABLE(test TEXT) AS $$
    WITH series AS (
        SELECT generate_series(0, 10) AS gen
    )
    SELECT
        'Test ' || series.gen as test
    FROM series;
$$ LANGUAGE sql;

GRANT EXECUTE ON FUNCTION public_api.test() TO anon_user;

Using curl to post to this function:

curl -X POST http://127.0.0.1:3000/rpc/test -H "Accept: application/json"

With the PostgREST 7.0.1 image this returns (expected behavior):

[{"test":"Test 0"}, 
 {"test":"Test 1"}, 
 {"test":"Test 2"}, 
 {"test":"Test 3"}, 
 {"test":"Test 4"}, 
 {"test":"Test 5"}, 
 {"test":"Test 6"}, 
 {"test":"Test 7"}, 
 {"test":"Test 8"}, 
 {"test":"Test 9"}, 
 {"test":"Test 10"}]

Taking this image down and replacing with the PostgREST 8.0.0 image the same command returns:

["Test 0", "Test 1", "Test 2", "Test 3", "Test 4", "Test 5", "Test 6", "Test 7", "Test 8", "Test 9", "Test 10"]
@wolfgangwalther wolfgangwalther self-assigned this Aug 31, 2021
wolfgangwalther added a commit to wolfgangwalther/postgrest that referenced this issue Aug 31, 2021
… type

This is a regression after changing responses for RPCs with INOUT or OUT arguments in PostgREST#1654.

Resolves PostgREST#1930.
@wolfgangwalther
Copy link
Member

wolfgangwalther commented Aug 31, 2021

Thanks for the report. It seems like we introduced that change in #1615. Seems to be easy to fix, too - I just created #1931.

wolfgangwalther added a commit to wolfgangwalther/postgrest that referenced this issue Aug 31, 2021
… type

This is a regression after changing responses for RPCs with INOUT or OUT arguments in PostgREST#1654.

Resolves PostgREST#1930.
wolfgangwalther added a commit to wolfgangwalther/postgrest that referenced this issue Sep 1, 2021
… type

This is a regression after changing responses for RPCs with INOUT or OUT arguments in PostgREST#1654.

Resolves PostgREST#1930.
wolfgangwalther added a commit to wolfgangwalther/postgrest that referenced this issue Sep 2, 2021
… type

This is a regression after changing responses for RPCs with INOUT or OUT arguments in PostgREST#1615.

Resolves PostgREST#1930.
steve-chavez pushed a commit that referenced this issue Sep 2, 2021
… type

This is a regression after changing responses for RPCs with INOUT or OUT arguments in #1615.

Resolves #1930.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging a pull request may close this issue.

2 participants