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

server: issue with uppercase enum type names in postgres (v2) #10314

Open
meetzaveri opened this issue Jul 3, 2024 · 0 comments
Open

server: issue with uppercase enum type names in postgres (v2) #10314

meetzaveri opened this issue Jul 3, 2024 · 0 comments
Labels
k/bug Something isn't working

Comments

@meetzaveri
Copy link
Member

Version Information

Server Version: 2.40

Environment

Cloud/OSS/EE

What is the current behaviour?

If a user defines enum type totally in UPPERCASE and references that enum as data type for specific column in table, the current behavior is that Hasura maps default to lowercase enum type which is resulting into an error suggesting that enum type does not exist. This error happens at query level.

What is the expected behaviour?

It should adhere to the case-sensitive practice based on the definition of enum type. So essentially it would map to exact enum type name as it was defined by user.

How to reproduce the issue?

I have an ENUM type defined with the enum type name in all caps (uppercase).
Now I am creating a table with one of its column having array of an enum type.

enum DDL

CREATE TYPE public."MOOD" AS ENUM ('sad', 'ok', 'happy');

table DDL

CREATE TABLE person (
  id UUID PRIMARY KEY,
  name TEXT,
  moods "MOOD"[]
);

Some seeds

INSERT INTO person (id, name, moods) VALUES (gen_random_uuid(), 'Alice', ARRAY['happy', 'ok']::"MOOD"[]);
INSERT INTO person (id, name, moods) VALUES (gen_random_uuid(), 'Bob', ARRAY['sad', 'sad', 'ok']::"MOOD"[]);

Then when I execute mutation

mutation updatePersonByPk {
  update_person_by_pk(pk_columns: 
    {id: "669aa150-d3d9-4a2b-9663-6e24bc12faf2"},  # replace id with the id of record as this id was taken in my example
    _set: {moods: ["happy"]}) {
    id
    moods
    name
  }
}

It throws the error such as

{
  "errors": [
    {
      "message": "type \"mood[]\" does not exist",
      "extensions": {
        "path": "$",
        "code": "constraint-error"
      }
    }
  ]
}

Screenshots or Screencast

Screenshot 2024-07-02 at 6 46 00 PM

Any possible solutions/workarounds you're aware of?

The workaround is to define enum type name in lowercase which we can reference in any table definition for column data type utilizing enum.

Keywords

enum postgres uppercase

@meetzaveri meetzaveri added the k/bug Something isn't working label Jul 3, 2024
@meetzaveri meetzaveri changed the title server: issue with uppercase enum type names in postgres server: issue with uppercase enum type names in postgres (v2) Jul 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
k/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant