-
Notifications
You must be signed in to change notification settings - Fork 2.8k
fix updating a column with multiple operators causing postgres query error (fix #3432) #3458
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
fix updating a column with multiple operators causing postgres query error (fix #3432) #3458
Conversation
|
Deploy preview for hasura-docs ready! Built with commit 3385027 |
86cab62 to
53061cd
Compare
|
Review app for commit 53061cd deployed to Heroku: https://hge-ci-pull-3458.herokuapp.com |
…s columns Review request by @lexi-lambda
|
Review app for commit 0c407d7 deployed to Heroku: https://hge-ci-pull-3458.herokuapp.com |
|
Review app for commit 3385027 deployed to Heroku: https://hge-ci-pull-3458.herokuapp.com |
|
Review app https://hge-ci-pull-3458.herokuapp.com is deleted |
Description
Using a column in multiple operators in an update mutation generates invalid SQL statement and causing Postgres query error. This PR makes a validation check and throws an appropriate error.
Query:-
Error:-
{ "errors": [ { "extensions": { "internal": { "statement": "WITH \"public_article__mutation_result_alias\" AS (UPDATE \"public\".\"article\" SET \"id\" = $1,\"id\" = (\"id\"+('2')::integer) WHERE (('true') AND (((((\"public\".\"article\".\"author_id\") = ($2)) AND ('true')) AND ('true')) AND ('true'))) RETURNING * ) SELECT json_build_object('affected_rows', (SELECT COUNT(*) FROM \"public_article__mutation_result_alias\" ) ) ", "prepared": true, "error": { "exec_status": "FatalError", "hint": null, "message": "multiple assignments to same column \"id\"", "status_code": "42601", "description": null }, "arguments": [ "(Oid 23,Just (\"\\NUL\\NUL\\NUL\\SOH\",Binary))", "(Oid 23,Just (\"\\NUL\\NUL\\NUL\\SOH\",Binary))" ] }, "path": "$", "code": "unexpected" }, "message": "postgres query error" } ] }Affected components
Related Issues
Fix #3432
Solution and Design
Check for same columns present in different operators and if any such column found, raise a validation exception by plumbing in operator names in error message.
Server checklist
Catalog upgrade
Does this PR change Hasura Catalog version?
Metadata
Does this PR add a new Metadata feature?
GraphQL
Breaking changes
Steps to test and verify
Reproduce the issue #3432, instead of unexpected, the server should throw validation error.
Limitations, known bugs & workarounds