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
👋
Try
I’ve tried this as well and the error is still there
hum :/ I stoped using pg enum for
text("type", { enum: [ 'a', 'b, '...']}).notNull()
so I thought it works the sameIt'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
Ah I see, thank you!
@Andrew Sherman is there a ticket to track for this?
I just came across this issue so I'm assuming it hasn't been fixed.
Same here still experiencing this
+1 this issue still seems to exist