fix: parse multiple statements with embedded semicolon#85
Open
piotrkira wants to merge 1 commit intotursodatabase:mainfrom
Open
fix: parse multiple statements with embedded semicolon#85piotrkira wants to merge 1 commit intotursodatabase:mainfrom
piotrkira wants to merge 1 commit intotursodatabase:mainfrom
Conversation
a508329 to
29ee493
Compare
Contributor
|
Thank you for your contribution @piotrkira. Could you please add tests that verify the code works as intended? |
Author
Good idea! Btw current tests already cover that functionality, not directly tho. So I'll add some tests. |
luisfvieirasilva
left a comment
There was a problem hiding this comment.
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.
since we're keeping the semicolumn (;) for the last statement, maybe we should keep for other ones as well. What do you think?
Suggested change
| stmt = statementsString[stmtBegin : i] | |
| stmt = statementsString[stmtBegin : i+1] |
Contributor
|
can we use our antlr parser instead @luisfvieirasilva ? |
29ee493 to
593db83
Compare
Author
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
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.
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