Drizzle TeamDT
Drizzle Teamโ€ข3y ago
Hocus

Prepare statement throws type error for enums. How to get type safety for prepared values

the status column in the schema is an enum like so:

 status: mysqlEnum("status", "PENDING", "ACCEPTED", "DECLINED")
      .notNull()
      .default("PENDING"),


and even type casting the placeholder does not work

  db.update(table).set({ status: sql.placeholder("status") as Status })


is there a proper way to get type safety in general for prepared statements?

Love the performance gains, but really bums me out that I loose all safeguards regarding types ๐Ÿ˜•
image.png
Was this page helpful?