Repository navigation
Use one foreign-key state in ALTER TABLE - #2764
Merged
manticore-projects merged 2 commits intoOct 11, 2026
Merged
manticore-projects merged 2 commits into
manticore-projects merged 2 commits into
Conversation
Contributor
|
Go ahead please. |
Delegate legacy FK accessors to the structured constraint, remove copied grammar state and the fallback renderer, and validate the current reference. Preserve quoted name parts and protect existing non-FK definitions. This follow-up is based on PR JSQLParser#2747 at 9be3636. Signed-off-by: minleejae <mmj9808@gmail.com>
minleejae
force-pushed
the
refactor/alter-foreign-key-state-20261011
branch
from
October 11, 2026 08:57
1371418 to
dd8b5c3
Compare
minleejae
marked this pull request as ready for review
October 11, 2026 08:58
This was referenced Oct 11, 2026
Signed-off-by: minleejae <mmj9808@gmail.com>
This was referenced Oct 11, 2026
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.
Purpose
Make ALTER foreign-key edits consistent across the structured and legacy APIs. For example, after parsing an ADD FOREIGN KEY,
setFkSourceTable("parent_history")currently changes the legacy getter while the SQL still references the original table.Current design (As-is)
After #2747 separates constraints from indexes,
AlterExpressionstill copies four FK properties and referential actions fromForeignKeyConstraint. Its renderer prefers the structured definition, so legacy edits can be ignored, replacement definitions leave stale getter values, and action column lists are absent from the copied state. A separate legacy renderer and validator path maintain these copies.Target design (To-be)
ForeignKeyConstraint/ForeignKeyReference. Remove the duplicate FK fields, action store, grammar copying and fallback renderer; delegate existing FK accessors to that definition.withFkSourceSchema()and validate the current structured target/columns without a second unqualified-table lookup. Document the editing and snapshot contracts.PK/UK fallback cleanup and separate DROP targets are handled by #2771. The FK creation guard uses the existing key accessors so it remains compatible when that follow-up removes their backing fields. This PR keeps the parent’s index/constraint separation and does not expand SQL grammar.
Validation
Java 17 Gradle
checkpasses: 9,964 tests, 9,939 passed, 25 skipped, zero failures/errors; grammar, formatting, Checkstyle, PMD, SpotBugs and coverage checks pass.15 FK regression cases plus one validator case cover MySQL/PostgreSQL mutation, rendering/reparsing, action column lists, quoted names, replacement/null handling and competing definitions. Running the FK cases on the parent produces 13 failures and two passing controls.
Before the parent merge, replayed 882 previously DB-validated DDL fixtures through the parser: 875 supported cases have unchanged AST inspection and SQL outputs; seven existing parse gaps remain. Error differences are generated grammar locations only. No fresh live DB replay.
Separate index and constraint ASTs (breaking API change) #2747 is now merged. Rebased only this follow-up onto current
master(cdbaf1ad), verified that its patch is unchanged, and reran the complete checks above.Integration check with the other independent refactors (Use one foreign-key state in ALTER TABLE #2764–Expose editable ALTER column identity actions #2768): all five patches apply without conflicts; full Java 17 Gradle
checkpasses with 10,030 tests (10,005 passed, 25 skipped). Replaying 882 previously DB-validated fixtures preserves the AST and both SQL outputs for 875 supported cases, with the same seven existing parse gaps and no semantic regression. No fresh database execution.The accessor-only compatibility adjustment for Separate ALTER key definitions from column drop targets #2771 was also verified with the complete Java 17 Gradle
check; all checks pass.