Skip to content

Commit

Permalink
fix: Allow match after unwind as defined by OpenCypher. (#531)
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-simons committed Dec 19, 2022
1 parent 90f5362 commit 88aead2
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ interface OngoingReadingWithWhere extends OngoingReading, ExposesMatch,
* @since 1.0
*/
interface OngoingReading
extends ExposesReturning, ExposesWith, ExposesUpdatingClause, ExposesUnwind, ExposesCreate,
extends ExposesReturning, ExposesWith, ExposesUpdatingClause, ExposesUnwind, ExposesCreate, ExposesMatch,
ExposesCall<OngoingInQueryCallWithoutArguments>, ExposesSubqueryCall {
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import org.neo4j.cypherdsl.core.renderer.Configuration;
import org.neo4j.cypherdsl.core.renderer.Dialect;
import org.neo4j.cypherdsl.core.renderer.Renderer;

/**
Expand Down Expand Up @@ -1408,4 +1409,19 @@ void testLabelRemoval() {

assertThat(correctQuery).isEqualTo("MATCH (n:`Wine`) WHERE id(n) = 1 REMOVE n:`Drink` RETURN id(n) AS id");
}

@Test // GH-524
void unwindWithoutWith() {

SymbolicName id = Cypher.name("id");
Node n = Cypher.node("Person").named("n");
Renderer renderer = Renderer.getRenderer(Configuration.newConfig().withDialect(Dialect.NEO4J_5).build());
Statement statement = Cypher.unwind(Cypher.parameter("ids"))
.as(id)
.match(n)
.where(n.elementId().isEqualTo(id))
.returning(n)
.build();
assertThat(renderer.render(statement)).isEqualTo("UNWIND $ids AS id MATCH (n:`Person`) WHERE elementId(n) = id RETURN n");
}
}
3 changes: 3 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,9 @@
| Those are shaded classes from Neo4j and we work around their changes.
-->
<exclude>org.neo4j.cypherdsl.parser.internal</exclude>

<!-- 2022.8.2, Not to be implemented by users, also a bug fix as it has been oversight -->
<exclude>org.neo4j.cypherdsl.core.StatementBuilder$OngoingReading</exclude>
</excludes>
</parameter>
</configuration>
Expand Down

0 comments on commit 88aead2

Please sign in to comment.