-
Notifications
You must be signed in to change notification settings - Fork 5
Insert parentheses based on precedence #78
Copy link
Copy link
Closed
Labels
good first issueOpportunity for newcomers to contribute to php-cypher-dslOpportunity for newcomers to contribute to php-cypher-dslsubject/query-readabilityIssues related to the readability of generated queriesIssues related to the readability of generated queriestype/enhancementNew feature or requestNew feature or request
Milestone
Metadata
Metadata
Assignees
Labels
good first issueOpportunity for newcomers to contribute to php-cypher-dslOpportunity for newcomers to contribute to php-cypher-dslsubject/query-readabilityIssues related to the readability of generated queriesIssues related to the readability of generated queriestype/enhancementNew feature or requestNew feature or request
Currently, parentheses are always inserted when creating an expression (unless
$insertParenthesesisfalse). This leads to less readable expressions: compare((a AND b) OR (c AND d))toa AND b OR c AND d.I propose to only insert parentheses when this is required by precedence rules. There is no explicit document on the precedence of operators in Cypher AFAIK, but it can be derived from the grammar:
IN,STARTS WITH,ENDS WITH,CONTAINS,=~,IS NULL,IS NOT NULL+,-(unary)^*,/,%+,-(binary)=,<>,<,>,<=,>=NOTANDXOROR