Skip to content

PostgreSQL: Support NOT NULL and NULL in CREATE DOMAIN - #2798

Open
LucaCappelletti94 wants to merge 7 commits into
upstream/alter-domainfrom
upstream/create-domain-nullability
Open

LucaCappelletti94 wants to merge 7 commits into
upstream/alter-domainfrom
upstream/create-domain-nullability

Conversation

@LucaCappelletti94

Copy link
Copy Markdown
Contributor

CREATE DOMAIN d AS INT NOT NULL fails with Expected: end of statement, found: NOT, and CREATE DOMAIN d AS INT NULL the same way, because parse_create_domain reads its constraints with parse_optional_table_constraint, which knows CHECK but not the nullability spellings of a domain. CREATE DOMAIN d AS INT DEFAULT 0 NOT NULL does parse, but the default expression swallows the NOT NULL and prints back as DEFAULT 0 IS NOT NULL.

CreateDomain.constraints now holds the DomainConstraint enum that ALTER DOMAIN ... ADD uses, with an added NULL variant, so [ CONSTRAINT name ] NOT NULL, NULL and CHECK (...) parse in any order and number, and table-only constraints such as PRIMARY KEY are refused. ALTER DOMAIN ... ADD NULL stays refused, as in PostgreSQL. The default expression is parsed in the column definition state that column defaults already use, so a trailing NOT NULL stays a constraint.

@codecov-commenter

codecov-commenter commented Nov 2, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.16%. Comparing base (e5e9bef) to head (642a973).

Additional details and impacted files
@@                  Coverage Diff                   @@
##           upstream/alter-domain    #2798   +/-   ##
======================================================
  Coverage                  83.15%   83.16%           
======================================================
  Files                         42       42           
  Lines                      36382    36399   +17     
  Branches                   36382    36399   +17     
======================================================
+ Hits                       30255    30272   +17     
  Misses                      2636     2636           
  Partials                    3491     3491           

☔ 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/create-domain-nullability branch from 6483aa6 to f4a1d8d Compare November 2, 2026 13:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants