diff --git a/modules/ROOT/pages/clauses/clause-composition.adoc b/modules/ROOT/pages/clauses/clause-composition.adoc index d3e1949d0..012cdad48 100644 --- a/modules/ROOT/pages/clauses/clause-composition.adoc +++ b/modules/ROOT/pages/clauses/clause-composition.adoc @@ -129,9 +129,25 @@ In a Cypher query, read and write clauses can take turns. The most important aspect of read-write queries is that the state of the graph also changes between clauses. [IMPORTANT] -==== A clause can never observe writes made by a later clause. -==== + +As of Cypher 25, read and write clauses can be combined in any order. +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. +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]. + + +.Combine write and read clauses without a separating `WITH` clause +[source, cypher] +---- +MATCH (j:Person {name: 'John'})-[:FRIEND]->(f) +SET f.degreesFromJohn = 1 +MATCH (f)-[:FRIEND]->(f2) +SET f2.degreesFromJohn = f.degreesFromJohn + 1 +RETURN f.name AS friendName, + f.degreesFromJohn AS friendDegree, + f2.name AS friendOfFriendName, + f2.degreesFromJohn AS friendOfFriendDegree +---- .Table of intermediate results and state of the graph between read and write clauses ====== diff --git a/modules/ROOT/pages/clauses/with.adoc b/modules/ROOT/pages/clauses/with.adoc index ebc2460dc..fb2b642b4 100644 --- a/modules/ROOT/pages/clauses/with.adoc +++ b/modules/ROOT/pages/clauses/with.adoc @@ -13,6 +13,9 @@ The `WITH` clause serves multiple purposes in Cypher: * xref:clauses/with.adoc#ordering-pagination[Order and paginate results] * xref:clauses/with.adoc#filter-results[Filter results] +[IMPORTANT] +As of Cypher 25, `WITH` is no longer required as a separator between a write and a read clause. + [[example-graph]] == Example graph A graph with the following schema is used for the examples below: diff --git a/modules/ROOT/pages/deprecations-additions-removals-compatibility.adoc b/modules/ROOT/pages/deprecations-additions-removals-compatibility.adoc index 6b176a145..d5e8e7ddb 100644 --- a/modules/ROOT/pages/deprecations-additions-removals-compatibility.adoc +++ b/modules/ROOT/pages/deprecations-additions-removals-compatibility.adoc @@ -200,6 +200,7 @@ RETURN count(p) AS count ---- | Queries no longer require xref:clauses/with.adoc[`WITH`] to transition between reading and writing operations. +For more information, see xref:clauses/clause-composition.adoc#cypher-clause-composition-rw-queries[Clause composition -> Read-write queries]. a| label:functionality[]