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

Cannot insert more than 1 row simultaneously into table with generated columns #4633

@medvesekg

Description

@medvesekg

Using

  • Hasura v1.2.0
  • Postgres 12.2

Steps to reproduce

  1. Create a fresh Hasura app on Heroku
  2. Create a table
    image
  3. Add generated column to table
ALTER TABLE people 
ADD COLUMN full_name text 
GENERATED ALWAYS AS (first_name || ' ' || last_name) STORED
  1. Inserting a single row works fine
    image

  2. Inserting more than one row gives an error
    image

{
  "errors": [
    {
      "extensions": {
        "internal": {
          "statement": "WITH \"people__mutation_result_alias\" AS (INSERT INTO \"public\".\"people\" ( \"first_name\", \"full_name\", \"last_name\", \"id\" ) VALUES (($1)::text, DEFAULT, ($2)::text, DEFAULT), (($3)::text, DEFAULT, ($4)::text, DEFAULT)  RETURNING * , CASE WHEN 'true' THEN NULL ELSE \"hdb_catalog\".\"check_violation\"('insert check constraint failed')  END ), \"people__all_columns_alias\" AS (SELECT  \"id\" , \"first_name\" , \"last_name\" , \"full_name\"  FROM \"people__mutation_result_alias\"      ) SELECT  json_build_object('affected_rows', (SELECT  COUNT(*)  FROM \"people__all_columns_alias\"      ) )        ",
          "prepared": true,
          "error": {
            "exec_status": "FatalError",
            "hint": null,
            "message": "cannot insert into column \"full_name\"",
            "status_code": "42601",
            "description": "Column \"full_name\" is a generated column."
          },
          "arguments": [
            "(Oid 25,Just (\"John\",Binary))",
            "(Oid 25,Just (\"Doe\",Binary))",
            "(Oid 25,Just (\"Jane\",Binary))",
            "(Oid 25,Just (\"Doe\",Binary))"
          ]
        },
        "path": "$.selectionSet.insert_people.args.objects",
        "code": "unexpected"
      },
      "message": "database query error"
    }
  ]
}

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions