JSqlParser icon indicating copy to clipboard operation
JSqlParser copied to clipboard

NotExpression parsing error

Open xsgao-github opened this issue 4 years ago • 1 comments
trafficstars

Describe the bug NotExpression is not parsed correctly.

To Reproduce Steps to reproduce the behavior:

  1. CCJSqlParserUtil.parseCondExpression("not not 1 = 1") generates following objects: NotExpression ( EqualsTo ( NotExpression ( 1 ) = 1 ) ). Instead, the result should be: NotExpression ( NotExpression ( EqualsTo (1 = 1) ) )
  2. CCJSqlParserUtil.parseCondExpression("not not not 1 = 1") yields Exception: net.sf.jsqlparser.JSQLParserException: Encountered unexpected token: "not" "NOT"

Expected behavior Based on SQL operator precedence and associativity, NOT operator should be evaluated after equal (=), and NOT operator should be evaluated from right to left.

System

  • Database you are using - irrelative
  • Java Version - 1.8
  • JSqlParser version - 4.0

xsgao-github avatar Apr 21 '21 22:04 xsgao-github

You are right, that not expressions are not truly hierarchical handled by JSqlParser. This would lead to heavy grammar refactoring, I think.

Is this a pressing feature you need?

wumpz avatar Apr 28 '21 10:04 wumpz