Skip to content

Fix precedence of unary NOT #107

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

Merged
merged 1 commit into from
Jun 6, 2019
Merged

Fix precedence of unary NOT #107

merged 1 commit into from
Jun 6, 2019

Conversation

benesch
Copy link
Contributor

@benesch benesch commented Jun 6, 2019

get_next_precedence deals with left-binding power, not right binding
power. Therefore, when it encounters a standalone NOT operator (i.e., a
"NOT" token that is not followed by "BETWEEN", "LIKE", or "IN"), it
should return 0, because unary NOT is not an infix operator, it's a
prefix operator, and therefore it has no left-binding power.

@nickolay this is as discussed in #93. Making this change does indeed mean that parsing DEFAULT doesn't need to do any special precedence hacks.

@benesch benesch requested a review from nickolay June 6, 2019 16:58
@coveralls
Copy link

Pull Request Test Coverage Report for Build 300

  • 3 of 3 (100.0%) changed or added relevant lines in 2 files are covered.
  • 2 unchanged lines in 2 files lost coverage.
  • Overall coverage decreased (-0.05%) to 91.433%

Files with Coverage Reduction New Missed Lines %
src/sqltokenizer.rs 1 90.97%
src/sqlparser.rs 1 91.28%
Totals Coverage Status
Change from base Build 287: -0.05%
Covered Lines: 3746
Relevant Lines: 4097

💛 - Coveralls

@nickolay
Copy link
Contributor

nickolay commented Jun 6, 2019

I would keep the const UNARY_NOT_PREC, otherwise this looks great.

get_next_precedence deals with left-binding power, not right binding
power. Therefore, when it encounters a standalone NOT operator (i.e., a
"NOT" token that is not followed by "BETWEEN", "LIKE", or "IN"), it
should return 0, because unary NOT is not an infix operator, it's a
prefix operator, and therefore it has no left-binding power.
@benesch
Copy link
Contributor Author

benesch commented Jun 6, 2019

I would keep the const UNARY_NOT_PREC, otherwise this looks great.

You bet. Done.

@benesch benesch merged commit fc5e662 into apache:master Jun 6, 2019
@benesch benesch deleted the prec branch June 6, 2019 21:26
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.

3 participants