Why does drizzle-zod refinements overwrite the nullability of the field?

I was previously on v0.5.1 and I could provide a typeOverrides object that specifies all the schemas that should be applied to createInsertSchema and createSelectSchema. Depending on the schema, the override would be applied and then the nullability of the column would be applied on top of the refinement. After upgrading to 0.8.2, it seems this is no longer the case and the website documentation even states it explicitly: https://orm.drizzle.team/docs/zod#refinements In the example on the site, preferences is a nullable json field. The way this example overwrites the nullability, you can easily insert null values into the preferences field but using the userSelectSchema to parse data coming out of the DB would fail. I use these schemas to validate data going into the DB and also data coming out. This helps with branded types and extensive use of jsonb fields. It made a lot of sense when I could refine the schema, and then have the nullability applied on top of the refinement. Can someone help me understand this?
Drizzle ORM - drizzle-zod
Drizzle ORM is a lightweight and performant TypeScript ORM with developer experience in mind.
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?