Inserting into columns of type Enum

Hi, any code written here was done in TypeScript and the database I’m connecting to is AWS Aurora PostgreSQL. (I’m on mobile, sorry about the format) I’ve defined an enum as follows: const CardType = pgEnum(‘CardType’, [‘VOCAB’, ‘GRAMMAR’]); I’m using it in a table as follows: const Card = pgTable(‘Card’, { type: CardType(‘type’).notNull(), // other fields }); When trying to insert into the Card table with: db.insert(Card).values({type: ‘VOCAB’, /other fields/}) I keep getting the error “column ‘type’ is of type cardtype but expression is of type character varying”. I’ve tried declaring the inserted object separately with type InferModel<typeof Card, “insert”>, but the error persists. Sorry if this is a very simple question. I’m quite new to using Drizzle and would appreciate any help I can get on this matter. Thank you!
9 Replies
rphlmr ⚡
rphlmr ⚡2y ago
👋 Try
type: 'VOCAB' as const
type: 'VOCAB' as const
Goldstair
GoldstairOP2y ago
I’ve tried this as well and the error is still there
rphlmr ⚡
rphlmr ⚡2y ago
hum :/ I stoped using pg enum for text("type", { enum: [ 'a', 'b, '...']}).notNull() so I thought it works the same
Andrii Sherman
It's Aws Data API issue. I'm aware about not all types support in AWS Data API. Going to fix it in 1 of next releases
Goldstair
GoldstairOP2y ago
Ah I see, thank you!
minsoju
minsoju2y ago
@Andrew Sherman is there a ticket to track for this?
Karam
Karam10mo ago
I just came across this issue so I'm assuming it hasn't been fixed.
davidML
davidML9mo ago
Same here still experiencing this
PGeyer
PGeyer7mo ago
+1 this issue still seems to exist
Want results from more Discord servers?
Add your server