cli icon indicating copy to clipboard operation
cli copied to clipboard

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")

Open victordelajarte opened this issue 1 year ago • 2 comments

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 avatar Nov 27 '23 17:11 victordelajarte

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

amerryma avatar Jan 02 '24 19:01 amerryma