这是indexloc提供的服务,不要输入任何密码
Skip to content

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

@rakeshkky

Description

@rakeshkky

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.

Metadata

Metadata

Assignees

Labels

c/serverRelated to serverk/bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions