Skip to content

Logical Operator Precedence (QUESTION) #1070

Closed

Description

@ebocher

Describe the question

I have a doubt about operator precedence
Indeed the following code

CCJSqlParserUtil.parseCondExpression("TYPE=1 or TYPE= 2 and OS=25", false);

return OrExpression

Shouldn't this be

return AndExpression due to the higher precedence of And ?

To Reproduce

CCJSqlParserUtil.parseCondExpression("TYPE=1 or TYPE= 2 and OS=25", false);

System

  • Database you are using
  • Java Version : >8
  • JSqlParser version : 3.2

Activity

  1. wumpz commented on Dec 6, 2020

    @wumpz
    Member

    IMHO no, since the evaluation of those trees is done from the leaves to the root. Therefore the AND is processed first. For example, if you process a numeric expression like 5 + 3 * 2 then you will get something like:

    ADDITION
           5
           MULTIPLICATION
                 3
                 2
    
  2. ebocher commented on Dec 7, 2020

    @ebocher
    Author

    Thanks
    I close it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions