Skip to content

Commit 746478d

Browse files
committed
Clarify precedence rules
1 parent 2921112 commit 746478d

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

cip/CIP2016-06-22-nested-updating-and-chained-subqueries.adoc

+16
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,22 @@ Note:: This mechanism allows guaranteed execution of `<Q2>` irrespective of the
168168

169169
Note:: In general, `<Q1>` is expected to be an updating query and it is recommended that implementations generate a warning if this is not the case (to inform the user that `<Q1>` is essentially superfluous).
170170

171+
==== Precedence of subquery chaining
172+
173+
This CIP proposes to distinguish between full (top-level) queries and argument queries.
174+
175+
A full top-level query is any Cypher query.
176+
In particular, a full top-level query may be formed by composing argument queries using subquery chaining or other query combinators (like `UNION`).
177+
178+
An argument query is a sequence of clauses that ends in either an updating clause or `RETURN`.
179+
An argument query may not contain subquery chaining or another query combinator.
180+
181+
These rules establish left-associative precedence of subquery chaining and other query combinators over argument queries.
182+
183+
In other words, `<Q1> UNION <Q2> WITH <Q3>` is always interpreted as `(<Q1> UNION <Q2>) WITH <Q3>` but never as `<Q1> UNION (<Q2> WITH <Q3>)`.
184+
185+
Note:: Subquery chaining and other query combinators may still be used from inside an argument query via inner nested subqueries.
186+
171187
==== Discarding variables in scope
172188

173189
Finally, this CIP proposes new shorthand syntax for discarding all variables in scope without discarding the cardinality of input records using `WITH|RETURN|YIELD NOTHING`.

0 commit comments

Comments
 (0)