Repository navigation
fix: read PostgreSQL NO INHERIT and named column NOT NULL constraints without a dialect - #2966
Merged
manticore-projects merged 1 commit intoDec 2, 2026
Conversation
… without a dialect Signed-off-by: minleejae <mmj9808@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PostgreSQL's
NO INHERITconstraint clause was read only withDialect.POSTGRESQL. Without a dialect,CREATE TABLE t (id INT CHECK (id > 0) NO INHERIT),CREATE TABLE t (id INT NOT NULL NO INHERIT),ALTER TABLE t ADD CONSTRAINT ck CHECK (id > 0) NO INHERITandALTER TABLE t ADD COLUMN c INT NOT NULL NO INHERITwere parse errors, while the table-levelNOT NULL column NO INHERITconstraint has parsed without a dialect since #2942. A named columnNOT NULL(id INT CONSTRAINT nn NOT NULL) parsed without a dialect, but as three unrelated column options.This change reads these forms with
Dialect.POSTGRESQLand without a dialect, never with another dialect, through the productions the dialect already uses:CHECK (...) NO INHERITin a column constraint, a table constraint andALTER TABLE ... ADD [CONSTRAINT name] CHECKsetsCheckConstraint.isNoInherit(). A table constraint also takesNO INHERITafter[NOT] ENFORCED, and is printed in the dialect's order (NO INHERIT NOT ENFORCED). A column constraint does not, as in PostgreSQL.[CONSTRAINT name] NOT NULL [NO INHERIT]on a column produces aNotNullConstraint, as withDialect.POSTGRESQL.The dialect check reuses
isPostgreSqlTableConstraintDialect().Compatibility: without a dialect,
CONSTRAINT nn NOT NULLon a column is now oneColumnOptionof kindCONSTRAINTthat holds aNotNullConstraintnamednn, instead of the optionsCONSTRAINT,nnandNOT NULL.toString()is unchanged. Other statements that already parsed keep their representation. MySQL, Oracle and the other dialects are unchanged: they still rejectNO INHERITand keep their reading ofCONSTRAINT nn NOT NULL. As withDialect.POSTGRESQL, a repeatedNO INHERITin a table constraint is still rejected, although PostgreSQL accepts it.Reference: PostgreSQL 18 CREATE TABLE (
column_constraint:NOT NULL [ NO INHERIT ],CHECK ( expression ) [ NO INHERIT ];table_constraint), ALTER TABLE (ADD table_constraint,ADD COLUMN).Validation
PostgreSqlCheckNoInheritTest,PostgreSqlColumnNotNullTest: the forms parse without a dialect, round-trip, and give the same model as withDialect.POSTGRESQL, inCREATE TABLEandALTER TABLE;NOT ENFORCED NO INHERITof a table constraint is printed in the dialect's order; the column constraint in that order and a repeated columnNO INHERITare rejected with and without the dialect; MySQL and Oracle still rejectNO INHERITand keep their reading ofCONSTRAINT nn NOT NULL. 14 of these cases fail on the base (2ba80d35c).UNIQUE NO INHERIT, repeated columnNO INHERIT, the column constraint withNOT ENFORCED NO INHERIT), except the repeated table-levelNO INHERITnoted above.gradle check(Spotless, Checkstyle, PMD, JaCoCo verification): 16,858 tests, 0 failures, 25 skipped.AI assistance: prepared with Claude Code.