Skip to content

Commit 6220cd1

Browse files
s1ckknutwalker
andcommitted
Fix simplification in GdsCypher
Co-Authored-By: Paul Horn <paul.horn@neotechnology.com>
1 parent 7cf6c92 commit 6220cd1

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

test-utils/src/main/java/org/neo4j/gds/GdsCypher.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
import static org.neo4j.gds.PropertyMapping.DEFAULT_VALUE_KEY;
5858
import static org.neo4j.gds.PropertyMapping.PROPERTY_KEY;
5959
import static org.neo4j.gds.RelationshipProjection.AGGREGATION_KEY;
60+
import static org.neo4j.gds.RelationshipProjection.INDEX_INVERSE_KEY;
6061
import static org.neo4j.gds.RelationshipProjection.ORIENTATION_KEY;
6162
import static org.neo4j.gds.RelationshipProjection.TYPE_KEY;
6263
import static org.neo4j.gds.RelationshipType.ALL_RELATIONSHIPS;
@@ -849,7 +850,8 @@ private static MinimalObject toMinimalObject(
849850
ElementIdentifier identifier
850851
) {
851852
MinimalObject properties = toMinimalObject(projection.properties(), true);
852-
if (properties.isEmpty() && matchesType(identifier.name, projection)) {
853+
854+
if (properties.isEmpty() && matchesType(identifier.name, projection) && allDefaults(projection)) {
853855
return MinimalObject.string(identifier.name);
854856
}
855857

@@ -861,10 +863,17 @@ private static MinimalObject toMinimalObject(
861863
if (projection.aggregation() != DEFAULT) {
862864
value.put(AGGREGATION_KEY, projection.aggregation().name());
863865
}
866+
if (projection.indexInverse()) {
867+
value.put(INDEX_INVERSE_KEY, projection.indexInverse());
868+
}
864869
properties.toObject().ifPresent(o -> value.put(PROPERTIES_KEY, o));
865870
return MinimalObject.map(value);
866871
}
867872

873+
private static boolean allDefaults(RelationshipProjection projection) {
874+
return projection.orientation() == NATURAL && projection.aggregation() == DEFAULT && !projection.indexInverse();
875+
}
876+
868877
private static boolean matchesType(String type, RelationshipProjection projection) {
869878
return projection.orientation() == NATURAL
870879
&& projection.aggregation() == DEFAULT

0 commit comments

Comments
 (0)