Repository navigation
fix: parse MySQL mixed ADD COLUMN groups - #2930
Merged
manticore-projects merged 2 commits intoNov 15, 2026
Merged
manticore-projects merged 2 commits into
manticore-projects merged 2 commits into
Conversation
Preserve parenthesized ADD declarations in source order using existing table-element models and traversal. Retain mutable column accessors and visit/deparse every mixed column, constraint and index declaration. Cover mixed order, constraints first, metadata validation, expression visitors and compatibility with column-only groups.
Update the backing group list directly when replacing or removing its first constraint or index. This preserves filtered-view semantics while letting SpotBugs observe the mutation without a suppression. Cover append when an element kind is absent and preservation of the remaining declarations when the first constraint is removed.
Contributor
|
thank you! |
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.
MySQL accepts columns, indexes and constraints together in a parenthesized ADD list,
but JSqlParser only read column definitions there:
Preserve these declarations in source order as TableElement nodes. Reuse the existing
table-definition traversal and deparser so every CHECK/default expression, index and
foreign-key target remains accessible. Existing column-only groups retain their
representation; the column accessor stays mutable, and the singular constraint/index
accessors expose the first matching declaration in a mixed group.
The new grammar applies without a dialect or with Dialect.MYSQL. Regression coverage
includes constraints before columns, interleaved constraints and indexes, accessor
mutation, custom deparsing, visitors, validation and malformed groups.
References: MySQL ALTER TABLE,
server table_element_list grammar.
Validation:
mutation tests). Checkstyle, SpotBugs, Spotless and JAR verification pass.
grammar ambiguity and Codacy pass. Maven Verify also passes on all three OSes.
all seven deparser outputs execute successfully on MySQL 8.4.13 with SHOW CREATE TABLE
postchecks in isolated databases.
across default/explicit dialect modes). It changes only the intended failing case and preserves previously parsed observations.
AI assistance: prepared with OpenAI Codex.