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

updating same column with different operators causing postgres query error #3432

Closed
rakeshkky opened this issue Nov 27, 2019 · 0 comments · Fixed by #3458
Closed

updating same column with different operators causing postgres query error #3432

rakeshkky opened this issue Nov 27, 2019 · 0 comments · Fixed by #3458
Assignees
Labels
c/server Related to server k/bug Something isn't working

Comments

@rakeshkky
Copy link
Member

rakeshkky commented Nov 27, 2019

If we try to update a column through an update mutation using multiple (> 1) operators, then it results in Postgres query error.

For a simple article table:-
Query:

mutation {
  update_article(
    _set: {id: 1}
    _inc: {id: 2}
    where: {author_id: {_eq: 1}}
  ){
    affected_rows
  }
}

Response:

{
  "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"
    }
  ]
}

Ideally, the server should make a validation check if a column is being updated using multiple operators.

@rakeshkky rakeshkky added k/bug Something isn't working c/server Related to server labels Nov 27, 2019
@rakeshkky rakeshkky self-assigned this Nov 27, 2019
rakeshkky added a commit to rakeshkky/graphql-engine that referenced this issue Dec 2, 2019
rakeshkky added a commit to rakeshkky/graphql-engine that referenced this issue Dec 2, 2019
@rakeshkky rakeshkky added the s/wip Status: This issue is a work in progress label Dec 2, 2019
@lexi-lambda lexi-lambda removed the s/wip Status: This issue is a work in progress label Dec 3, 2019
polRk pushed a commit to polRk/graphql-engine that referenced this issue Feb 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c/server Related to server k/bug Something isn't working
Projects
None yet
2 participants