-
Notifications
You must be signed in to change notification settings - Fork 10
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
Fixes bug splitting the statements into commands #346
Conversation
…ands Co-authored-by: Isak Nilsson <[email protected]>
🦋 Changeset detectedLatest commit: 5ccba29 The changes in this PR will be included in the next version bump. This PR includes changesets to release 5 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
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.
Mostly LGTM, but would we not get the same issue with unfinished strings/escaped sequences? (If so, we might as well add tests for these too)
And if my summary of the issue (see comment) is correct, would we encounter it for single line comments?
@@ -610,8 +610,9 @@ function parseToCommand( | |||
|
|||
return { type: 'parse-error', start, stop }; | |||
} | |||
const statement = inputstream.getText(start.start, stop.stop); | |||
return { type: 'cypher', statement, start: start, stop: stop }; | |||
const stopToken = stop ?? tokens.at(-1); |
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.
Double checking my understanding - I would explain like:
"When ANTLR can't finish the parsing (but can tokenize) because a comment/string/escaped sequence is unfinished we get here with stop===null"
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.
The problem if we just a comment is that's not passed to the parser, so the CST is empty, therefore because the parser expects something, it errors and cannot find a stop. Strings and backticked elements are not on the hidden channel, so they are passed to the parser
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.
aha, your response jogged my memory - comments are removed just like blank space when tokenizing, so what would be the stop-token when parsing to command doesnt exist
Think changeset-message is off then, the issue is not with "non-finished multiline comments" (that's more like the bug in the other PR right) but rather "queries ending in a comment"
approving so you can merge once that's adjusted
What
When splitting the commands, we try to parse the input as cypher or console commands, etc. If all of that fails, we default to taking the full query if a cypher statement could not be parsed, but we were taking a
stop
token that could possibly be null. This PR just defaults to taking the full stream when that token is null:Why
Because we were blowing up in multiline comments (where the parsing tree would be empty):