drizzle-team / drizzle-orm

Headless TypeScript ORM with a head. Runs on Node, Bun and Deno. Lives on the Edge and yes, it's a JavaScript ORM too 😅
https://orm.drizzle.team
Apache License 2.0
24.25k stars 621 forks source link

[BUG]: Error setting default enum field values #2299

Open Malin88 opened 5 months ago

Malin88 commented 5 months ago

What version of drizzle-orm are you using?

0.29.5

What version of drizzle-kit are you using?

0.21.1

Describe the Bug

After update drizzle-kit to version 0.21.1 I cannot set default values for enum field.

export const userStatusEnum = pgEnum("status", ["inactive", "active", "banned"]);

createTable( "users", {
   status: userStatusEnum("status").default('inactive').notNull()
})

Returns error: invalid input value for enum status: "inactive". Before update everything works correctly

Expected behavior

Set the default status field value to "inactive".

Environment & setup

No response

Alshafei2430 commented 5 months ago

I have the same error.

DanielSintimbrean commented 5 months ago

Same here

hyqshr commented 4 months ago

same

alexcloudstar commented 3 months ago

Same

amit548 commented 3 months ago

Same 😒

amit548 commented 3 months ago

Hey guys, I understand what is the main problem. We should use a different and unique name for pgEnum. pgEnum name and field name should not be the same. change pgEnum("status") to pgEnum("user_status")

trykers commented 2 months ago

Same

lukeramljak commented 6 days ago

Thank you @amit548!