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

Generating types not working for enums: Field name 'request_status' works fine in the UI, but when the types are generated, it uses other values ("PENDING" | "SUCCESS" | "ERROR") #844

Open
victordelajarte opened this issue Nov 27, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@victordelajarte
Copy link

victordelajarte commented Nov 27, 2023

Bug report

  • [ X ] I confirm this is a bug with Supabase, not with my own application.
  • [ X ] I confirm I have searched the Docs, GitHub Discussions, and Discord.

Describe the bug

Field name 'request_status' works fine in the UI, but when the types are generated, it uses other values ("PENDING" | "SUCCESS" | "ERROR")

To Reproduce

In a Nuxt app with supabase, I created 2 enum types as such, then when generating the types, I get statusA: "PENDING" | "SUCCESS" | "ERROR" for toto_bug instead of the correct statusA: Database["public"]["Enums"]["my_custom_status"] for toto_fine. But it works as expected for both tables in the UI editor (I can use 'approved' for instance).

CREATE TYPE "public"."request_status" AS ENUM (
    'pending',
    'approved',
    'refused',
    'cancelled'
);

CREATE TABLE IF NOT EXISTS "public"."toto_bug" (
    "id" "uuid" DEFAULT "gen_random_uuid"() NOT NULL,
    "statusP" "public"."request_status" DEFAULT 'pending'::"public"."request_status" NOT NULL,
    "statusA" "public"."request_status" DEFAULT 'approved'::"public"."request_status" NOT NULL,
    "statusR" "public"."request_status" DEFAULT 'refused'::"public"."request_status" NOT NULL,
    "statusC" "public"."request_status" DEFAULT 'cancelled'::"public"."request_status" NOT NULL
);


CREATE TYPE "public"."my_custom_status" AS ENUM (
    'pending',
    'approved',
    'refused',
    'cancelled'
);

CREATE TABLE IF NOT EXISTS "public"."toto_fine" (
    "id" "uuid" DEFAULT "gen_random_uuid"() NOT NULL,
    "statusP" "public"."my_custom_status" DEFAULT 'pending'::"public"."my_custom_status" NOT NULL,
    "statusA" "public"."my_custom_status" DEFAULT 'approved'::"public"."my_custom_status" NOT NULL,
    "statusR" "public"."my_custom_status" DEFAULT 'refused'::"public"."my_custom_status" NOT NULL,
    "statusC" "public"."my_custom_status" DEFAULT 'cancelled'::"public"."my_custom_status" NOT NULL
);

Expected behavior

A clear and concise description of what you expected to happen.

Screenshots

Capture d’écran 2023-11-27 à 18 37 13

System information

  • OS: macOS
  • Browser (if applies) [e.g. chrome, safari]
  • Version of supabase (CLI): 1.106.1
  • @nuxtjs/supabase: 1.1.3
  • Version of Node.js: v18.18.2

Additional context

Add any other context about the problem here.

@victordelajarte victordelajarte added the bug Something isn't working label Nov 27, 2023
@saltcod saltcod changed the title Field name 'request_status' works fine in the UI, but when the types are generated, it uses other values ("PENDING" | "SUCCESS" | "ERROR") Generating types not working for enums: Field name 'request_status' works fine in the UI, but when the types are generated, it uses other values ("PENDING" | "SUCCESS" | "ERROR") Nov 27, 2023
@saltcod saltcod transferred this issue from supabase/supabase Nov 27, 2023
@amerryma
Copy link

amerryma commented Jan 2, 2024

Guessing it has to do with this? I'm thinking it is clashing somehow.

https://github.com/supabase/pg_net/blob/master/sql/pg_net.sql#L259

@toficofi
Copy link

Same issue here! Renaming to a different enum for now

@sweatybridge sweatybridge transferred this issue from supabase/cli Nov 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants