-
Notifications
You must be signed in to change notification settings - Fork 7
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
fix: parse multiple statements with embedded semicolon #85
base: main
Are you sure you want to change the base?
fix: parse multiple statements with embedded semicolon #85
Conversation
a508329
to
29ee493
Compare
Thank you for your contribution @piotrkira. Could you please add tests that verify the code works as intended? |
Good idea! Btw current tests already cover that functionality, not directly tho. So I'll add some tests. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @piotrkira for the PR!
Just a few comments
- Looks like the code fails when we have a quote inside another one. For instance, something like
select "banana'"; select 1
- The issue that you tagged is related to the PR but it's not exactly the same problem. It aims to fix function appendStatementPartAndExecuteIfFinished, implementing a similar logic that you used here 😄
internal/db/db.go
Outdated
if embedded['\''] || embedded['"'] || char != ';' { | ||
continue | ||
} | ||
stmt = statementsString[stmtBegin : i] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since we're keeping the semicolumn (;
) for the last statement, maybe we should keep for other ones as well. What do you think?
stmt = statementsString[stmtBegin : i] | |
stmt = statementsString[stmtBegin : i+1] |
can we use our antlr parser instead @luisfvieirasilva ? |
29ee493
to
593db83
Compare
Thanks, such cases are covered now. |
593db83
to
0ad5e0a
Compare
Sqlparser is not maintained anymore, as it was used just for this simple thing I've decided to re implement logic of spiting statements into one simple function. Related-to: tursodatabase#50
Description
Sqlparser is not maintained anymore, as it was used just for this simple thing I've decided to re implement logic of spiting statements into one simple function.
Related Issues