Skip to content

UDF call returns null #439

@imor

Description

@imor

Describe the bug
UDF call returns null when it shouldn't

To Reproduce
Add the following before the last rollback in function_calls.sql test file:

    rollback to savepoint a;

    create table account(
        id serial primary key,
        email varchar(255) not null,
        name text null
    );

    create function returns_account()
        returns account language sql stable
    as $$ select id, email, name from account; $$;

    insert into account(email, name)
    values
        ('[email protected]', null),
        ('[email protected]', 'bat'),
        ('[email protected]', 'cat');

    -- comment on table account is e'@graphql({"totalCount": {"enabled": true}})';

    select jsonb_pretty(graphql.resolve($$
        query {
            returnsAccount {
                id
                email
                nodeId
                __typename
            }
        }
    $$));

    select jsonb_pretty(graphql.resolve($$
        query {
            returnsAccount {
                email
                nodeId
            }
        }
    $$));

Expected behavior
Call to returnsAccount should return an object.

Screenshots
N/A

Versions:

  • PostgreSQL: 15
  • pg_graphql version v0.4.1

Additional context
The generated sql returns no row when a column in the returned table is null. E.g. this sql returns nothing: select ra.* from returns_account() ra where ra is not null;. In the test above if the 'aardvark' row's name column is made non-null then the test passes. In the returned row, even a single null value in any of the columns fails this test.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions