Skip to content

Support MySQL CHECK constraint enforcement - #2528

Open
minleejae wants to merge 1 commit into
JSQLParser:masterfrom
minleejae:feat/mysql-check-enforcement-2526
Open

Support MySQL CHECK constraint enforcement#2528
minleejae wants to merge 1 commit into
JSQLParser:masterfrom
minleejae:feat/mysql-check-enforcement-2526

Conversation

@minleejae

Copy link
Copy Markdown
Contributor

Fixes #2526.

What

  • Parse optional ENFORCED and NOT ENFORCED clauses after MySQL table-level CHECK constraints.
  • Preserve the tri-state syntax on CheckConstraint through nullable Boolean getEnforced(): null when omitted, true for ENFORCED, and false for NOT ENFORCED.
  • Deparse the explicit clause losslessly.
  • Add a focused AST and parse/deparse regression test.

Server validation

The exact test statement was executed successfully on MySQL 8.4.11. information_schema.TABLE_CONSTRAINTS reported chk_positive as ENFORCED = YES and chk_cap as ENFORCED = NO.

MySQL grammar reference: https://dev.mysql.com/doc/refman/8.4/en/create-table.html

Testing

  • ./gradlew clean test --tests net.sf.jsqlparser.statement.create.MySQLCreateTableConstraintTest --tests net.sf.jsqlparser.statement.create.CreateTableTest --tests net.sf.jsqlparser.statement.alter.AlterTest --no-daemon --no-build-cache -Dorg.gradle.vfs.watch=false
  • ./gradlew spotlessApply check --no-daemon --no-build-cache -Dorg.gradle.vfs.watch=false

Both completed successfully.

AI assistance

OpenAI Codex was used to assemble and execute the parser/server comparison and prepare this change. The syntax was checked against the MySQL 8.4 documentation and an actual MySQL 8.4.11 server.

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.

[BUG] 5.4-SNAPSHOT: MySQL CHECK constraint ENFORCED clauses fail to parse

1 participant