drizzle-orm icon indicating copy to clipboard operation
drizzle-orm copied to clipboard

[BUG]: drizzle-zod not overriding optional

Open Jamess-Lucass opened this issue 6 months ago • 0 comments

What version of drizzle-orm are you using?

0.32.2

What version of drizzle-kit are you using?

0.23.2

Describe the Bug

When wanting to override a nullable column, drizzle-zod does not respect when you completely override this with a zod type that is not nullable.

const userTable = pgTable("users", {
  name: text("name"),
});

const userSchema = createInsertSchema(userTable, {
  name: z.string(),
});

type UserSchema = TypeOf<typeof userSchema>;
// type UserSchema = {
//   name?: string | null | undefined; // nullable, despite me overriding it with z.string()
// }

Expected behavior

I would expect UserSchema to result in

type UserSchema = {
  name: string
}

Environment & setup

drizzle-zod 0.5.1 drizzle-orm 0.32.2 drizzle-kit 0.23.2

Jamess-Lucass avatar Aug 05 '24 22:08 Jamess-Lucass