Skip to content

PostgreSQL: Parse NULLS [NOT] DISTINCT on column UNIQUE constraints - #2738

Merged
LucaCappelletti94 merged 2 commits into
mainfrom
upstream/unique-nulls-not-distinct
Oct 28, 2026
Merged

LucaCappelletti94 merged 2 commits into
mainfrom
upstream/unique-nulls-not-distinct

Conversation

@LucaCappelletti94

Copy link
Copy Markdown
Contributor

CREATE TABLE t (u INT UNIQUE NULLS NOT DISTINCT) failed with Expected: ',' or ')' after column definition, found: NULLS. PostgreSQL 15 and later accept NULLS [ NOT ] DISTINCT after a column's UNIQUE (https://www.postgresql.org/docs/current/sql-createtable.html), and sqlparser already parses the modifier on a table-level UNIQUE constraint and on CREATE INDEX.

The column option now reads the modifier into the nulls_distinct field that UniqueConstraint already carries for the table-level form and prints it back. Like the table-level form, it is not gated on a dialect.

@LucaCappelletti94 LucaCappelletti94 added enhancement New feature or request PostgreSQL labels Oct 27, 2026
@codecov-commenter

codecov-commenter commented Oct 27, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.40%. Comparing base (14eadef) to head (9e65260).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2738      +/-   ##
==========================================
+ Coverage   82.38%   82.40%   +0.01%     
==========================================
  Files          42       42              
  Lines       35339    35342       +3     
  Branches    35339    35342       +3     
==========================================
+ Hits        29115    29122       +7     
  Misses       2678     2678              
+ Partials     3546     3542       -4     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@LucaCappelletti94
LucaCappelletti94 force-pushed the upstream/unique-nulls-not-distinct branch from eceeccc to 8d4569a Compare October 28, 2026 11:29
@LucaCappelletti94

Copy link
Copy Markdown
Contributor Author

Thanks @sabir-akhadov-localstack for the review, I will now merge the PR.

cc @alamb

@LucaCappelletti94
LucaCappelletti94 added this pull request to the merge queue Oct 28, 2026
Merged via the queue into main with commit e15e9ab Oct 28, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request PostgreSQL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants