fix(sql): handle unbalanced quotes in SQL line comments#6684
Merged
bluestreak01 merged 3 commits intomasterfrom Jan 20, 2026
Merged
fix(sql): handle unbalanced quotes in SQL line comments#6684bluestreak01 merged 3 commits intomasterfrom
bluestreak01 merged 3 commits intomasterfrom
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…ine comment Co-Authored-By: Claude Opus 4.5 <[email protected]>
Contributor
[PR Coverage check]😍 pass : 11 / 18 (61.11%) file detail
|
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.
Summary
Fixes #6671
When a SQL line comment contains an unbalanced single quote (e.g.,
-- magic '), the lexer enters string-parsing mode and incorrectly consumes tokens past the newline, causing subsequent SQL tokens to be lost from the query.Root cause: The
GenericLexertreats'as the start of a string literal regardless of context. WhenSqlUtil.fetchNext()is in line comment mode and receives a token that spans across a newline (because the lexer consumed it as part of a quoted string), the simple newline checkChars.equals(cs, '\n')fails since the token is a multi-character string.Fix: When in line comment mode, check if the token contains a newline character. If found, reposition the lexer to just after the newline using
backTo()to properly reset the lexer state.Test plan
testLineCommentWithUnbalancedQuotetest that reproduces the issueGenericLexerTesttests pass (39 tests)🤖 Generated with Claude Code