Skip to content

Commit ac38963

Browse files
GH-2649 - Upgrade Cypher-DSL to 2023.0.0.
Closes #2649.
1 parent ec26447 commit ac38963

File tree

5 files changed

+24
-23
lines changed

5 files changed

+24
-23
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
<checkstyle.skip>${skipTests}</checkstyle.skip>
7878
<checkstyle.version>8.40</checkstyle.version>
7979
<classgraph.version>4.8.149</classgraph.version>
80-
<cypher-dsl.version>2022.6.0</cypher-dsl.version>
80+
<cypher-dsl.version>2023.0.0</cypher-dsl.version>
8181
<dist.id>spring-data-neo4j</dist.id>
8282
<dist.key>SDNEO4J</dist.key>
8383
<flatten-maven-plugin.version>1.2.5</flatten-maven-plugin.version>

src/main/java/org/springframework/data/neo4j/core/TemplateSupport.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,17 +211,17 @@ Statement toStatement(NodeDescription<?> nodeDescription) {
211211
.with(Functions.collect(rootNodes).as(Constants.NAME_OF_ROOT_NODE))
212212
.optionalMatch(relationships)
213213
.where(Functions.id(relationships).in(Cypher.parameter(relationshipIds)))
214-
.with(Constants.NAME_OF_ROOT_NODE, Functions.collectDistinct(relationships).as(Constants.NAME_OF_SYNTHESIZED_RELATIONS).asExpression())
214+
.with(Constants.NAME_OF_ROOT_NODE, Functions.collectDistinct(relationships).as(Constants.NAME_OF_SYNTHESIZED_RELATIONS))
215215
.optionalMatch(relatedNodes)
216216
.where(Functions.id(relatedNodes).in(Cypher.parameter(relatedNodeIds)))
217217
.with(
218218
Constants.NAME_OF_ROOT_NODE,
219219
Cypher.name(Constants.NAME_OF_SYNTHESIZED_RELATIONS).as(Constants.NAME_OF_SYNTHESIZED_RELATIONS),
220-
Functions.collectDistinct(relatedNodes).as(Constants.NAME_OF_SYNTHESIZED_RELATED_NODES).asExpression()
220+
Functions.collectDistinct(relatedNodes).as(Constants.NAME_OF_SYNTHESIZED_RELATED_NODES)
221221
)
222222
.unwind(Constants.NAME_OF_ROOT_NODE).as(rootNodeIds)
223223
.with(
224-
Cypher.name(rootNodeIds).as(Constants.NAME_OF_TYPED_ROOT_NODE.apply(nodeDescription).getValue()).asExpression(),
224+
Cypher.name(rootNodeIds).as(Constants.NAME_OF_TYPED_ROOT_NODE.apply(nodeDescription).getValue()),
225225
Cypher.name(Constants.NAME_OF_SYNTHESIZED_RELATIONS),
226226
Cypher.name(Constants.NAME_OF_SYNTHESIZED_RELATED_NODES))
227227
.orderBy(queryFragments.getOrderBy())

src/main/java/org/springframework/data/neo4j/core/mapping/CypherGenerator.java

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,16 @@
3434
import java.util.function.UnaryOperator;
3535
import java.util.regex.Pattern;
3636

37+
import javax.lang.model.SourceVersion;
38+
3739
import org.apiguardian.api.API;
3840
import org.neo4j.cypherdsl.core.Condition;
3941
import org.neo4j.cypherdsl.core.Conditions;
4042
import org.neo4j.cypherdsl.core.Cypher;
4143
import org.neo4j.cypherdsl.core.Expression;
4244
import org.neo4j.cypherdsl.core.FunctionInvocation;
4345
import org.neo4j.cypherdsl.core.Functions;
46+
import org.neo4j.cypherdsl.core.IdentifiableElement;
4447
import org.neo4j.cypherdsl.core.MapProjection;
4548
import org.neo4j.cypherdsl.core.Node;
4649
import org.neo4j.cypherdsl.core.Parameter;
@@ -55,6 +58,7 @@
5558
import org.neo4j.cypherdsl.core.SymbolicName;
5659
import org.neo4j.cypherdsl.core.renderer.Configuration;
5760
import org.neo4j.cypherdsl.core.renderer.Renderer;
61+
import org.neo4j.cypherdsl.core.utils.Assertions;
5862
import org.springframework.data.domain.Sort;
5963
import org.springframework.data.mapping.MappingException;
6064
import org.springframework.data.mapping.PersistentProperty;
@@ -111,12 +115,12 @@ public StatementBuilder.OrderableOngoingReadingAndWith prepareMatchOf(NodeDescri
111115

112116
Node rootNode = createRootNode(nodeDescription);
113117

114-
List<Expression> expressions = new ArrayList<>();
118+
List<IdentifiableElement> expressions = new ArrayList<>();
115119
expressions.add(rootNode.getRequiredSymbolicName());
116120
expressions.add(Functions.id(rootNode).as(Constants.NAME_OF_INTERNAL_ID));
117121
expressions.add(Functions.elementId(rootNode).as(Constants.NAME_OF_ELEMENT_ID));
118122

119-
return match(rootNode).where(conditionOrNoCondition(condition)).with(expressions.toArray(new Expression[] {}));
123+
return match(rootNode).where(conditionOrNoCondition(condition)).with(expressions.toArray(IdentifiableElement[]::new));
120124
}
121125

122126
public StatementBuilder.OngoingReading prepareMatchOf(NodeDescription<?> nodeDescription,
@@ -126,12 +130,12 @@ public StatementBuilder.OngoingReading prepareMatchOf(NodeDescription<?> nodeDes
126130

127131
StatementBuilder.OngoingReadingWithoutWhere match = prepareMatchOfRootNode(rootNode, initialMatchOn);
128132

129-
List<Expression> expressions = new ArrayList<>();
133+
List<IdentifiableElement> expressions = new ArrayList<>();
130134
expressions.add(Functions.collect(Functions.id(rootNode)).as(Constants.NAME_OF_SYNTHESIZED_ROOT_NODE));
131135

132136
return match
133137
.where(conditionOrNoCondition(condition))
134-
.with(expressions.toArray(new Expression[]{}));
138+
.with(expressions.toArray(IdentifiableElement[]::new));
135139
}
136140

137141
public StatementBuilder.OngoingReading prepareMatchOf(NodeDescription<?> nodeDescription,
@@ -163,15 +167,15 @@ public StatementBuilder.OngoingReading prepareMatchOf(NodeDescription<?> nodeDes
163167
};
164168

165169
relationship = relationship.named(Constants.NAME_OF_SYNTHESIZED_RELATIONS);
166-
List<Expression> expressions = new ArrayList<>();
170+
List<IdentifiableElement> expressions = new ArrayList<>();
167171
expressions.add(Functions.collect(Functions.id(rootNode)).as(Constants.NAME_OF_SYNTHESIZED_ROOT_NODE));
168172
expressions.add(Functions.collect(Functions.id(targetNode)).as(Constants.NAME_OF_SYNTHESIZED_RELATED_NODES));
169173
expressions.add(Functions.collect(Functions.id(relationship)).as(Constants.NAME_OF_SYNTHESIZED_RELATIONS));
170174

171175
return match
172176
.where(conditionOrNoCondition(condition))
173177
.optionalMatch(relationship)
174-
.with(expressions.toArray(new Expression[]{}));
178+
.with(expressions.toArray(IdentifiableElement[]::new));
175179
}
176180

177181
@NonNull
@@ -619,6 +623,7 @@ public Collection<Expression> createReturnStatementForMatch(Neo4jPersistentEntit
619623
expression = Cypher.property(property.substring(0, firstDot), tail);
620624
} else {
621625
try {
626+
Assertions.isTrue(SourceVersion.isIdentifier(property), "Name must be a valid identifier.");
622627
expression = Cypher.name(property);
623628
} catch (IllegalArgumentException e) {
624629
if (e.getMessage().endsWith(".")) {

src/test/java/org/springframework/data/neo4j/documentation/repositories/custom_queries/MovieRepository.java

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,7 @@
3131

3232
// tag::domain-results-impl[]
3333
import org.neo4j.cypherdsl.core.Cypher;
34-
import org.neo4j.cypherdsl.core.Expression;
3534
import org.neo4j.cypherdsl.core.Functions;
36-
import org.neo4j.cypherdsl.core.NamedPath;
37-
import org.neo4j.cypherdsl.core.Node;
38-
import org.neo4j.cypherdsl.core.Statement;
3935

4036
// end::domain-results-impl[]
4137

@@ -85,13 +81,13 @@ class DomainResultsImpl implements DomainResults {
8581
@Override
8682
public List<MovieEntity> findMoviesAlongShortestPath(PersonEntity from, PersonEntity to) {
8783

88-
Node p1 = node("Person").withProperties("name", parameter("person1"));
89-
Node p2 = node("Person").withProperties("name", parameter("person2"));
90-
NamedPath shortestPath = shortestPath("p").definedBy(
84+
var p1 = node("Person").withProperties("name", parameter("person1"));
85+
var p2 = node("Person").withProperties("name", parameter("person2"));
86+
var shortestPath = shortestPath("p").definedBy(
9187
p1.relationshipBetween(p2).unbounded()
9288
);
93-
Expression p = shortestPath.getRequiredSymbolicName();
94-
Statement statement = Cypher.match(shortestPath)
89+
var p = shortestPath.getRequiredSymbolicName();
90+
var statement = Cypher.match(shortestPath)
9591
.with(p, listWith(name("n"))
9692
.in(Functions.nodes(shortestPath))
9793
.where(anyNode().named("n").hasLabels("Movie")).returning().as("mn")

src/test/java/org/springframework/data/neo4j/integration/reactive/ReactiveNeo4jClientIT.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
import org.neo4j.cypherdsl.core.Statement;
2121
import org.neo4j.cypherdsl.core.executables.ExecutableResultStatement;
2222
import org.neo4j.driver.Query;
23-
import org.neo4j.driver.QueryRunner;
2423
import org.neo4j.driver.Record;
24+
import org.neo4j.driver.SimpleQueryRunner;
2525
import org.neo4j.driver.async.AsyncQueryRunner;
2626
import org.neo4j.driver.reactivestreams.ReactiveQueryRunner;
2727
import org.neo4j.driver.reactivestreams.ReactiveResult;
@@ -176,7 +176,7 @@ public Publisher<Record> fetchWith(ReactiveQueryRunner reactiveQueryRunner) {
176176
}
177177

178178
@Override
179-
public <T> List<T> fetchWith(QueryRunner queryRunner, Function<Record, T> function) {
179+
public <T> List<T> fetchWith(SimpleQueryRunner queryRunner, Function<Record, T> function) {
180180
throw new UnsupportedOperationException();
181181
}
182182

@@ -186,12 +186,12 @@ public <T> List<T> fetchWith(QueryRunner queryRunner, Function<Record, T> functi
186186
}
187187

188188
@Override
189-
public ResultSummary streamWith(QueryRunner queryRunner, Consumer<Stream<Record>> consumer) {
189+
public ResultSummary streamWith(SimpleQueryRunner queryRunner, Consumer<Stream<Record>> consumer) {
190190
throw new UnsupportedOperationException();
191191
}
192192

193193
@Override
194-
public ResultSummary executeWith(QueryRunner queryRunner) {
194+
public ResultSummary executeWith(SimpleQueryRunner queryRunner) {
195195
throw new UnsupportedOperationException();
196196
}
197197

0 commit comments

Comments
 (0)