Drizzle with Zod throws type errors with simple `numeric` example
For example, I define a PostgreSQL table with an input schema:
When using this in my API:
I get a type error thrown:
This is specifically a problem with the
numeric
and decimal
data types. Other standard data types work fine.
Any ideas on a fix?7 Replies
Bump
your numeric data can be null when you are grabbing it from db, you can either make it notNull in drizzle schema or nullable in zod to allow null values
@pacto shouldn't
createInsertSchema
infer the schema from the pgTable
definition?@Simon did you find a solution? I'm having the same problem with a custom Date datatype
ahh.. I think it's exactOptionalPropertyTypes in tsconfig
Yeah that is what was throwing the TypeError 🙃
Did you manage to fix it? I guess you are also using
@effect/schema
as I've seen you there too 😛 but they require that exactOptionalPropertyTypes
I think?I'm not really using effect schema with drizzle. I think I'm just not using the zod schema at all, instead just explicitly passing the relevant key/values as the values argument in my query..