Normalize constraint options to prevent differences between pgquery and generic parser#1142
Closed
wreulicke wants to merge 4 commits intosqldef:masterfrom
Closed
Normalize constraint options to prevent differences between pgquery and generic parser#1142wreulicke wants to merge 4 commits intosqldef:masterfrom
wreulicke wants to merge 4 commits intosqldef:masterfrom
Conversation
wreulicke
commented
Feb 26, 2026
Comment on lines
+5304
to
+5306
| if constraintOptions == nil { | ||
| return false, false | ||
| } |
Contributor
Author
There was a problem hiding this comment.
Sorry, I am not sure that this assumption is correct.
Codecov Report❌ Patch coverage is
🚀 New features to boost your workflow:
|
wreulicke
commented
Feb 26, 2026
| }) | ||
| } | ||
|
|
||
| func TestPsqldefConstraintWithPgqueryFallback(t *testing.T) { |
Contributor
Author
There was a problem hiding this comment.
I cannot add a test that contains pgquery fallback in tests.yaml.
I moved this from yaml.
ed86b23
Contributor
Author
gfx
added a commit
that referenced
this pull request
Mar 4, 2026
The generic parser didn't support CREATE INDEX IF NOT EXISTS, causing
psqldef to fall back to the pgquery parser. This led to unnecessary
foreign key constraint migrations due to differing constraintOptions
representations between the two parsers (nil vs {false, false}).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
github-merge-queue bot
pushed a commit
that referenced
this pull request
Mar 4, 2026
The generic parser didn't support CREATE INDEX IF NOT EXISTS, causing
psqldef to fall back to the pgquery parser. This led to unnecessary
foreign key constraint migrations due to differing constraintOptions
representations between the two parsers (nil vs {false, false}).
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Merged
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.
There are trivial parse result differences between pgquery and generic parser.
This causes unnecessary migrations around constraints by psqldef.
This PR fixes this behavior.
The generic parser does not support
CREATE INDEX IF NOT EXISTSbecause it is not supported in MySQL.Therefore, we should not change parser.y I think.
Reproduction
psqdef 3.5.0 or higher can reproduce this inconsistency.
Just apply psqldef with following DDL twice.
current behavior
psqdef will apply following changes
expected behavior
even if contains
IF NOT EXISTSpsqldef will apply no changes.