Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: replace mulit statement parsing with comment aware parsing #691

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

evadnoob
Copy link

@evadnoob evadnoob commented Jan 24, 2022

existing multi-statement parsing was not aware of lines that start with -- this new function implementation could be extended in the future to support end of line comments as well as embedded comments.

for now I chose to go with a very naive scanner/lexer, it could easily be converted to use a state machine to emit statements, but this method is simple enough to be placed directly in migrate with little changes. Possibly good enough for now.

Copy link
Member

@dhui dhui left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you hit issues with ; inside comments (or commented out statements)?
multistmt is intentionally naive for simplicity.
Maybe it's better to make multistmt configurable with different parsers. Then you could use DB specific parsers...

Also, any new code should have adequate test coverage.

@@ -1,6 +1,6 @@
package main

import "github.com/golang-migrate/migrate/v4/internal/cli"
import "github.com/getoutreach/migrate/v4/internal/cli"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Undo your import changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants