Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes schema diff generation when indexes are declared without an explicit name (e.g., INDEX (col)), by normalizing them to MySQL’s default auto-naming behavior so diffs match what SHOW CREATE TABLE returns.
Changes:
- Auto-assign names to unnamed (non-PRIMARY) indexes during
CREATE TABLEparsing using MySQL’s “first column + optional _2/_3…” convention. - Adjust
ALTER TABLE ... ADD INDEXformatting to safely omit index names when empty (as a fallback). - Add/adjust tests to validate unnamed-index normalization and diff behavior (including duplicates and UNIQUE).
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| pkg/statement/parse_create_table.go | Auto-names unnamed indexes during parsing to match MySQL normalization. |
| pkg/statement/parse_create_table_test.go | Updates expectations for unnamed index names in parsing tests. |
| pkg/statement/diff.go | Updates ADD INDEX formatting to not emit empty backticked names. |
| pkg/statement/diff_test.go | Adds coverage for unnamed index normalization and diff stability. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
aparajon
approved these changes
Mar 2, 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.
A Pull Request should be associated with an Issue.
Fixes #645