drizzle-team / drizzle-team/drizzle-orm

[BUG]: notNull() constraint on array field not reflected in generated SQL

Open
#5,013 0 comments 0 reactions 0 assignees View on GitHub
bug bug/fixed-in-beta
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.44.7

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

0.31.6

### Other packages

_No response_

### Describe the Bug

**Schema definition**

```ts
export const emailTemplatesTable = pgTable(
'email_templates',
{
...,
values: varchar({ length: 20 }).notNull().array(),
...,
},
(table) => [...]
);
```

**Expected output (with NOT NULL)**

```sql
"values" varchar(20)[] NOT NULL,
```

**Actual output from drizzle-kit generate**

```sql
"values" varchar(20)[],
```

The `.notNull()` constraint is not being respected when used on an array column. It seems the `array()` method is overriding or discarding the `notNull()` flag in the generated SQL.

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.