Insert parentheses based on precedence #78
Labels
good first issue
Opportunity for newcomers to contribute to php-cypher-dsl
subject/query-readability
Issues related to the readability of generated queries
type/enhancement
New feature or request
Milestone
Currently, parentheses are always inserted when creating an expression (unless
$insertParentheses
isfalse
). 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)=
,<>
,<
,>
,<=
,>=
NOT
AND
XOR
OR
The text was updated successfully, but these errors were encountered: