Skip to content
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 parsing of identifiers after % symbol #927

Merged
merged 2 commits into from
Jul 21, 2023
Merged

Conversation

alamb
Copy link
Contributor

@alamb alamb commented Jul 20, 2023

Fixes a bug in parsing 'c%d1where thed` was accidentally consumed.

Introduced in #913 released in sqlparser-rs 036.0

Closes #926

@alamb
Copy link
Contributor Author

alamb commented Jul 20, 2023

If/when this is merged, I plan to make a 0.36.1 release that includes this fix

Some(sch) if self.dialect.is_identifier_start('%') => {
self.tokenize_identifier_or_keyword([ch, *sch], chars)
}
_ => self.consume_and_return(chars, Token::Mod),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the bug fix. At is at this point the % has been consumed by chars.next() so calling consume_and_return` skips another character by accident

It probably doesn't matter for ' ' but it does matter for everything else in this match arm

@coveralls
Copy link

coveralls commented Jul 20, 2023

Pull Request Test Coverage Report for Build 5616064223

  • 26 of 28 (92.86%) changed or added relevant lines in 3 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.03%) to 87.158%

Changes Missing Coverage Covered Lines Changed/Added Lines %
tests/sqlparser_common.rs 17 19 89.47%
Totals Coverage Status
Change from base Build 5604302362: 0.03%
Covered Lines: 15494
Relevant Lines: 17777

💛 - Coveralls

@alamb alamb mentioned this pull request Jul 20, 2023
@alamb
Copy link
Contributor Author

alamb commented Jul 20, 2023

@izveigor or @ankrgyl I wonder if you have a few moments to review this PR? It is a 2 line code change with some tests

Copy link
Contributor

@izveigor izveigor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@alamb
Copy link
Contributor Author

alamb commented Jul 21, 2023

Thanks for the reviews @izveigor and @crepererum -- I should point out that I studied the rest of the change carefully and I did not find similar bugs in the handling of @ or #.

@alamb alamb merged commit 3a41215 into apache:main Jul 21, 2023
9 checks passed
@alamb alamb deleted the alamb/fix_parser branch July 21, 2023 09:55
serprex pushed a commit to serprex/sqlparser-rs that referenced this pull request Nov 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Regression: c1%c5 is parsed as c1 % 5 (not an identifier) in sqlparser 0.36.0
4 participants