Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

[Feature Request] Supports @nullsNotDistinct column attribute

Open
#2,747 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
25/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Quiet
Tech stack
postgresql, sqlite, typescript
Domain
backend, databases

Research direction

This is a cross-dialect feature: the schema layer must accept a new @nullsNotDistinct column attribute, and the query/migration generators must emit NULLS NOT DISTINCT for postgresql and recent sqlite while compiling null-aware unique constraints for other dialects. Start by tracing how an existing attribute such as @unique is parsed and how unique indices are generated per provider, then run the provider test suites to see current coverage. Done means the attribute is accepted, NULLs compare equal for uniqueness on supporting databases, and documented fallbacks exist for the rest.

Written by the indexing model from the issue text.

Description

Is your feature request related to a problem? Please describe.
There is currently no good way to enforce uniqueness on nullable columns when you want two NULL values considered the same.

Describe the solution you'd like
For postgresql & recent versions of sqlite, use NULLS NOT DISTINCT, for other DB, compile queries to null aware operators and their equivalent and @@unique to partial/filtered unique indices.

Describe alternatives you've considered
Use some sentinel values that is not NULL on that column or some generated column. However, whether as an ad-hoc solution or plugin implemented by the user, or as a plugin/new feature added to zenstack itself, it's messy to work with due to a lack of a common null-ish value across various data types except for NULL, as well as need to insert dummy rows to satisfy referential integrity constraint on other tables when the said column is a foreign key.

Additional context
If any support for databases like SQL Server or Oracle were to be added, we should still retain the default defined behavior of considering nulls to be distinct by generating queries and filtered unique indices to enforce the inverse, rather than allow the whims of individual DBMS to define the behavior.

Dominant language
TypeScript
Stars
2.9k
Forks
157
Avg merge
11h 42m
Merged PRs (30d)
20

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from zenstackhq/zenstack

All issues in zenstackhq/zenstack

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.