From 3ed1ca99590aaa7242f43d834320d479aeb3d86e Mon Sep 17 00:00:00 2001 From: Stefan Plantikow Date: Mon, 16 Oct 2017 17:29:47 +0200 Subject: [PATCH] Clarify precedence rules --- ...2-nested-updating-and-chained-subqueries.adoc | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/cip/CIP2016-06-22-nested-updating-and-chained-subqueries.adoc b/cip/CIP2016-06-22-nested-updating-and-chained-subqueries.adoc index c4487baf85..6df6ec1b0b 100644 --- a/cip/CIP2016-06-22-nested-updating-and-chained-subqueries.adoc +++ b/cip/CIP2016-06-22-nested-updating-and-chained-subqueries.adoc @@ -168,6 +168,22 @@ Note:: This mechanism allows guaranteed execution of `` irrespective of the Note:: In general, `` 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 `` is essentially superfluous). +==== Precedence of subquery chaining + +This CIP proposes to distinguish between full (top-level) queries and argument queries. + +A full top-level query is any Cypher query. +In particular, a full top-level query may be formed by composing argument queries using subquery chaining or other query combinators (like `UNION`). + +An argument query is a sequence of clauses that ends in either an updating clause or `RETURN`. +An argument query may not contain subquery chaining or another query combinator. + +These rules establish left-associative precedence of subquery chaining and other query combinators over argument queries. + +In other words, ` UNION WITH ` is always interpreted as `( UNION ) WITH ` but never as ` UNION ( WITH )` (The same rule applies to `THEN`). + +Note:: Subquery chaining and other query combinators may still be used from inside an argument query via inner nested subqueries. + ==== Discarding variables in scope 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`.