Skip to content

fix: ignore omitted filter variables on function collections - #664

Open
Indian-boult wants to merge 1 commit into
supabase:masterfrom
Indian-boult:fix/function-optional-filter-variable
Open

Indian-boult wants to merge 1 commit into
supabase:masterfrom
Indian-boult:fix/function-optional-filter-variable

Conversation

@Indian-boult

Copy link
Copy Markdown

Fixes #617

Functions that return setof <table> are exposed as collections and take the usual connection args like filter and orderBy. When a filter used a variable that was left out of variables, table collections dropped that filter but function collections failed with "Encountered Absent value while transforming between GraphQL intermediate object notation and JSON".

The error came from read_func_call_args. It converted every field arg to JSON, including the connection args, even though FunctionCallBuilder::to_sql only passes args that map to a SQL function arg. The nested Absent inside filter made gson_to_json fail. Now only args that map to a function arg are converted. The connection builder still reads filter and orderBy and skips absent values the same way it does for tables.

The new issue_617 test runs the query from the issue against a table and a function. An omitted variable inside orderBy on a function collection hit the same error and is now ignored too, which matches tables. Function args themselves behave as before.

Functions that return `setof <table>` accept connection args such as
`filter` and `orderBy` next to their own args. read_func_call_args
converted all of them to JSON, but only the function's own args are
passed to the SQL call. A filter that uses an omitted variable holds a
nested Absent value, so the conversion failed with "Encountered `Absent`
value while transforming between GraphQL intermediate object notation
and JSON".

Only convert args that map to a SQL function arg. The connection
builder already reads filter and orderBy and skips absent values, the
same as it does for table collections.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Inconsistent handling of optional filter variables for SETOF SQL functions gives "Encountered Absent value" error

1 participant