Skip to content

Commit 973006c

Browse files
Clarify removal of update boundary (#1276)
1 parent 91ccf74 commit 973006c

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

modules/ROOT/pages/clauses/clause-composition.adoc

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,25 @@ In a Cypher query, read and write clauses can take turns.
129129
The most important aspect of read-write queries is that the state of the graph also changes between clauses.
130130

131131
[IMPORTANT]
132-
====
133132
A clause can never observe writes made by a later clause.
134-
====
133+
134+
As of Cypher 25, read and write clauses can be combined in any order.
135+
That is, a write clause followed by a read clause no longer requires a separating xref:clauses/with.adoc[`WITH`] clause in order for the read clause to observe the changes made by a preceding write clause.
136+
For example, the following query, in which the changes made by a write clause (xref:clauses/set.adoc[`SET`]) are observed by a subsequent `MATCH` clause without an intermediate `WITH` clause, is valid using Cypher 25 but not link:https://neo4j.com/docs/cypher-manual/current/clauses/with/#combine-write-and-read-clauses[Cypher 5].
137+
138+
139+
.Combine write and read clauses without a separating `WITH` clause
140+
[source, cypher]
141+
----
142+
MATCH (j:Person {name: 'John'})-[:FRIEND]->(f)
143+
SET f.degreesFromJohn = 1
144+
MATCH (f)-[:FRIEND]->(f2)
145+
SET f2.degreesFromJohn = f.degreesFromJohn + 1
146+
RETURN f.name AS friendName,
147+
f.degreesFromJohn AS friendDegree,
148+
f2.name AS friendOfFriendName,
149+
f2.degreesFromJohn AS friendOfFriendDegree
150+
----
135151

136152
.Table of intermediate results and state of the graph between read and write clauses
137153
======

modules/ROOT/pages/clauses/with.adoc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ The `WITH` clause serves multiple purposes in Cypher:
1313
* xref:clauses/with.adoc#ordering-pagination[Order and paginate results]
1414
* xref:clauses/with.adoc#filter-results[Filter results]
1515

16+
[IMPORTANT]
17+
As of Cypher 25, `WITH` is no longer required as a separator between a write and a read clause.
18+
1619
[[example-graph]]
1720
== Example graph
1821
A graph with the following schema is used for the examples below:

modules/ROOT/pages/deprecations-additions-removals-compatibility.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ RETURN count(p) AS count
200200
----
201201

202202
| Queries no longer require xref:clauses/with.adoc[`WITH`] to transition between reading and writing operations.
203+
For more information, see xref:clauses/clause-composition.adoc#cypher-clause-composition-rw-queries[Clause composition -> Read-write queries].
203204

204205
a|
205206
label:functionality[]

0 commit comments

Comments
 (0)