-
Notifications
You must be signed in to change notification settings - Fork 522
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
Semicolon Detection Fails for "--" in Strings in SQL Statements #699
Comments
Ye this is a bit unfortunate, I suppose you could move the semicolon to a new line, or wrap that statement in a The SQL parser is quite basic and does the bare minimum. Open to suggestions on how this could be improved. |
Certainly, I can manually adjust the SQL, but for my scenario, which involves programmatically generating migrations from For now, my temporary workaround is to regex my arrows from I don't really see any solutions that doesn't require complicating |
Yep, that's an excellent example.
Pretty much. Which gets us into the territory of writing a full-blown SQL parser, otherwise we're always fighting a new edge case. To make matters worse, there's always some subtle dialect-specific difference. I'll keep this issue open and continue to think this through in the background. I wonder if you could wrap your entire dumped schema with all statements within: -- +goose Up
-- +goose StatementBegin
... your entire schema here
-- +goose StatementEnd This tells A bit more background on these annotations can be found here: https://pressly.github.io/goose/blog/2022/overview-sql-file/#multiple-statements |
When executing SQL migrations, the parser misses the semicolon and incorrectly merges statements if a string contains "--" after a space, mistakenly interpreting it as the start of a comment. This issue occurs even though the "--" is part of a string and should not be treated as a comment. For example:
This results in syntax errors when running migrations, as seen below:
The issue appears to be in the semicolon detection logic
endsWithSemicolon(line string) bool
:goose/internal/sqlparser/parser.go
Lines 302 to 321 in d4a4dc3
The text was updated successfully, but these errors were encountered: