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

Inserting into a single char field fails #6814

@sean-bennett112

Description

@sean-bennett112

Tested on 2.0.0-alpha.8 and 2.0.0-alpha.9.

If I create a table with nothing but a single char type:

create table if not exists public.test_bug (
    single_char char not null
);

And expose it via Hasura:

- table:
    schema: public
    name: test_bug
  insert_permissions:
  - role: user
    permission:
      columns:
      - single_char
      check: {}
  select_permissions:
  - role: user
    permission:
      columns:
      - single_char
      filter: {}

Trying to insert into that table with the below query fails with the below error message:

mutation MyMutation {
  insert_test_bug_one(object: {single_char: "x"}) {
    single_char
  }
}
{
  "errors": [
    {
      "extensions": {
        "path": "$.selectionSet.insert_test_bug_one.args.object",
        "code": "data-exception"
      },
      "message": "value too long for type character(1)"
    }
  ]
}

If I then alter the column to have type text:

alter table test_bug alter COLUMN single_char type text;

Running the same query gives the following response:

{
  "data": {
    "insert_test_bug_one": {
      "single_char": "'x'"
    }
  }
}

Note the extraneous single quotes around the character, which is what prevents it from being inserted into the char type.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions