Fix: #340 Add comment handling and related tests for migration functionality#344
Merged
Conversation
dkropachev
approved these changes
Sep 13, 2025
Contributor
|
@itsfuad , thanks, what a great PR. |
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.
This pull request improves the migration system by introducing logic to correctly handle SQL comments in migration files, ensuring that regular comments (including trailing comments after statements) are ignored during migration execution. It also adds comprehensive tests to verify this behavior and documents the new logic for clarity.
Migration logic improvements:
isCommentfunction to distinguish regular SQL comments from callback commands, ensuring only valid statements and callbacks are processed during migrations (migrate/migrate.go).migrate/migrate.go).Testing enhancements:
TestMigrationWithTrailingCommenttest to verify that migrations with trailing comments succeed without error (migrate/migrate_test.go).TestIsCommenttest suite to validate the behavior of the newisCommentfunction for various statement types (migrate/migrate_test.go).IsCommentfunction for use in tests and other packages (migrate/export_test.go).Documentation updates:
applyMigrationfunction, clarifying the distinction between SQL statements, callback commands, and regular comments (migrate/migrate.go).What fixed
#340