Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: Extending insert schemas makes nullable optional fields into required #4187

Open
1 task done
elieven opened this issue Feb 27, 2025 · 2 comments · May be fixed by #4360
Open
1 task done

[BUG]: Extending insert schemas makes nullable optional fields into required #4187

elieven opened this issue Feb 27, 2025 · 2 comments · May be fixed by #4360
Labels
bug Something isn't working

Comments

@elieven
Copy link

elieven commented Feb 27, 2025

Report hasn't been filed before.

  • I have verified that the bug I'm about to report hasn't been filed before.

What version of drizzle-orm are you using?

0.39.3

What version of drizzle-kit are you using?

0.30.4

Other packages

[email protected]

Describe the Bug

const someTable = sqliteTable("some_table", {
  id: integer().primaryKey(),
  frequired: text().notNull(),
  foptional: text(),
})

const somethingInsertSchema = createInsertSchema(someTable, {
  foptional: schema => schema.email()
})

const someThing: z.infer<typeof somethingInsertSchema> = {
  frequired: "babajii"
}

In this example the type for someThing looks like this:

const someThing: {
    frequired: string;
    foptional: string | null;
    id?: number | undefined;
}

and there is a type error ts: Property 'foptional' is missing in type '{ frequired: string; }' but required in type '{ frequired: string; foptional: string | null; id?: number | undefined; }'.

@elieven elieven added the bug Something isn't working label Feb 27, 2025
@elieven
Copy link
Author

elieven commented Feb 27, 2025

I'd send a code sandbox but even literally just importing the lib with no other deps gives some bs errors about ( when I don't even have any in my singular ts file....

@makeanewgame
Copy link

I get the same error unless I add notNull to the schema.
drizzle-kit: 0.30.5
drizzle-orm: 0.40.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants