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 3db7f6f commit d62e720
Show file tree
Hide file tree
Showing 2 changed files with 17 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");
}
}

0 comments on commit d62e720

Please sign in to comment.