Skip to content

Add support for comparison chains #62

@marijnvanwezel

Description

@marijnvanwezel

Currently, the expression $a->gt($b)->gt($c) is allowed, but gets compiled to:

(a > b) > c

However, Cypher supports comparison chains, meaning that something like a > b > c is allowed. This expression is equivalent to a > b AND b > c, while the expression above first evaluates the LHS to a boolean, and then compares that resulting boolean to c.

This extends to all comparison operators and is not limited to three terms. It is even possible to combine comparison operators, e.g.:

a > b >= c = d

Which is equivalent to a > b AND b >= c AND c = d.

Possible implementation

Change the way parentheses are inserted, and do not insert them if the LHS of a comparison operator is also a comparison operator.

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions