Skip to content

feat: share PostgreSQL foreign key enforcement attributes - #2695

Merged
manticore-projects merged 1 commit into
JSQLParser:masterfrom
minleejae:feat/pg18-constraint-enforcement
Sep 24, 2026
Merged

manticore-projects merged 1 commit into
JSQLParser:masterfrom
minleejae:feat/pg18-constraint-enforcement

Conversation

@minleejae

Copy link
Copy Markdown
Contributor

PostgreSQL 18 accepts ENFORCED and NOT ENFORCED on foreign keys, but JSqlParser currently rejects these clauses in table constraints and column REFERENCES definitions. This prevents consumers from inspecting or rewriting DDL that deliberately disables enforcement.

This change stores the optional enforcement flag in ConstraintAttributes and shares attribute parsing across CREATE/ALTER table constraints and column references. CHECK constraints delegate their existing enforcement accessors to the same state, avoiding duplicate storage and rendering. Column references stop before a following NOT NULL; NOT VALID remains a table-constraint form.

Validation:

  • Full Gradle check with Java 17, including grammar ambiguity and static analysis.
  • Regression tests cover AST mutation, omitted/true/false flags, attribute ordering, CREATE/ALTER, CHECK accessor compatibility, following column options, and malformed/duplicate clauses.
  • Executed 22 accepted cases on PostgreSQL 18.6 in original, toString(), and StatementDeParser forms. Compared constraint catalogs and enforcement behavior, including deferred and NOT VALID constraints. Two invalid column-reference cases are rejected by both PostgreSQL and the parser.

Reference: PostgreSQL 18 CREATE TABLE.

Signed-off-by: minleejae <mmj9808@gmail.com>
@manticore-projects
manticore-projects merged commit 63d65ed into JSQLParser:master Sep 24, 2026
10 checks passed
@manticore-projects

Copy link
Copy Markdown
Contributor

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants