You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If using an enum as an array (array of enum values) the actual enum column name is not quoted. This causing an error if the enum name contains uppercase characters (IE: camelcase) as postgres will default to folding to lowercase if not quoted. My example is having an enum called supplierSpecialism, which is just an enum of strings. In my TS file I use that enum in the below table:
If I generate it using drizzle-kit generate:pg it will output the supplier table below:
CREATETABLEIF NOT EXISTS "supplier" (
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
"can_tender"boolean DEFAULT false NOT NULL,
"user_owner_id" uuid,
"specialisms" supplierSpecialism[] DEFAULT ARRAY[]::"supplierSpecialism"[] NOT NULL,
"name"varcharNOT NULL,
"type""supplierType"NOT NULL,
"is_completed"boolean DEFAULT false NOT NULL
);
While you're here, also notice how the enum supplierType is properly quoted, so enums are fine in general, but are NOT quoted when being used as an array. Running the sql in the pg terminal will result in an error regarding how the supplierspecialism type cannot be found, but wrapping it in quotes (IE: "supplierSpecialism"[]) fixes the issue
PS: If anyone is stuck here then just use snake case naming convention for enums. Don't be pedantic like me :)
Expected behavior
Enum columns to also be quoted when being used as an array
Environment & setup
No response
The text was updated successfully, but these errors were encountered:
What version of
drizzle-orm
are you using?0.29.5
What version of
drizzle-kit
are you using?0.20.18
Describe the Bug
If using an enum as an array (array of enum values) the actual enum column name is not quoted. This causing an error if the enum name contains uppercase characters (IE: camelcase) as postgres will default to folding to lowercase if not quoted. My example is having an enum called
supplierSpecialism
, which is just an enum of strings. In my TS file I use that enum in the below table:If I generate it using
drizzle-kit generate:pg
it will output thesupplier
table below:While you're here, also notice how the enum
supplierType
is properly quoted, so enums are fine in general, but are NOT quoted when being used as an array. Running the sql in the pg terminal will result in an error regarding how the supplierspecialism type cannot be found, but wrapping it in quotes (IE:"supplierSpecialism"[]
) fixes the issuePS: If anyone is stuck here then just use snake case naming convention for enums. Don't be pedantic like me :)
Expected behavior
Enum columns to also be quoted when being used as an array
Environment & setup
No response
The text was updated successfully, but these errors were encountered: