drizzle-team / drizzle-team/drizzle-orm

[BUG]: $inferInsert and InferInsertModel do not include nullable fields.

Open
#4,294 8 comments 4 reactions 0 assignees View on GitHub
bug bug/cant-reproduce priority
Dominant language
TypeScript
Stars
35.8k
Forks
1.6k
Avg merge
2d 7h
Merged PRs (30d)
4

Description

### Report hasn't been filed before.

- [x] 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.40.1

### What version of `drizzle-kit` are you using?

0.30.5

### Other packages

_No response_

### Describe the Bug

When defining a schema, $inferInsert and InferInsertModel do not include/infer fields that are nullable.

For example:

`
export const bases = pgTable('bases', {
status: varchar().notNull(),
id: uuid().primaryKey().defaultRandom(),
name: varchar().notNull(),
description: text()
});
`

export type InsertBase = InferInsertModel;

In the above schema, description is not included in InsertBase. It will only be included if you make it notNull().

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.