drizzle-team / drizzle-orm

Headless TypeScript ORM with a head. Runs on Node, Bun and Deno. Lives on the Edge and yes, it's a JavaScript ORM too 😅
https://orm.drizzle.team
Apache License 2.0
24.78k stars 656 forks source link

[BUG]: drizzle-zod not overriding optional #2755

Open Jamess-Lucass opened 3 months ago

Jamess-Lucass commented 3 months ago

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

yantakus commented 3 months ago

UP. I can confirm this problem exists in the latest drizzle-zod.

jimmysafe commented 1 month ago

still no update on this?