drizzle-team / drizzle-team/drizzle-orm-docs

Outdated example syntax in Constraint docs

Open
#435 1 comment 2 reactions 0 assignees View on GitHub
Dominant language
MDX
Stars
241
Forks
401
Avg merge
5h 44m
Merged PRs (30d)
1

Description

https://orm.drizzle.team/docs/indexes-constraints

The examples in the docs for table constraints (unique, check, etc) show an object return syntax for the extraConfig callback:

```ts
export const userNulls = pgTable('user_nulls_example', {
id: integer('id').unique("custom_name", { nulls: 'not distinct' }),
}, (t) => ({
unq: unique().on(t.id).nullsNotDistinct()
}));
```

looks like that syntax was deprecated [by a commit for RLS](https://github.com/drizzle-team/drizzle-orm/blob/05e88e44857b0f6017be1e2d1d5ebee53c7336ca/drizzle-orm/src/pg-core/table.ts) about a month ago & now it expects an array return:

```ts
export const userNulls = pgTable('user_nulls_example', {
id: integer('id').unique("custom_name", { nulls: 'not distinct' }),
}, (t) => [
unique().on(t.id).nullsNotDistinct()
]);
```

would also be helpful to add a note or something for this change since it's breaking from how constraints used to work in drizzle

thanks!

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.