Skip to content

Commit

Permalink
AUTO: Fixes #1952: apoc.meta.stats for 4.1.0.8 fails whereas 4.1.0.3 …
Browse files Browse the repository at this point in the history
…succeeds when a rel is back ticked (#1966)

Co-authored-by: Giuseppe Villani <[email protected]>
  • Loading branch information
github-actions[bot] and vga91 authored Jun 4, 2021
1 parent 14644dd commit 96a7ecd
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import java.util.Iterator;

import static apoc.export.cypher.formatter.CypherFormatterUtils.cypherNode;
import static apoc.util.Util.quote;

public class DatabaseSubGraph implements SubGraph
{
Expand Down Expand Up @@ -85,15 +86,15 @@ public Iterable<Label> getAllLabelsInUse() {
public long countsForRelationship(Label start, RelationshipType type, Label end) {
String startNode = cypherNode(start);
String endNode = cypherNode(end);
String relationship = String.format("[r:%s]", type.name());
String relationship = String.format("[r:%s]", quote(type.name()));
return transaction.execute(String.format("MATCH %s-%s->%s RETURN count(r) AS count", startNode, relationship, endNode))
.<Long>columnAs("count")
.next();
}

@Override
public long countsForNode(Label label) {
return transaction.execute(String.format("MATCH (n:%s) RETURN count(n) AS count", label.name()))
return transaction.execute(String.format("MATCH (n:%s) RETURN count(n) AS count", quote(label.name())))
.<Long>columnAs("count")
.next();
}
Expand Down
16 changes: 16 additions & 0 deletions core/src/test/java/apoc/meta/MetaTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -1073,4 +1073,20 @@ public void testMetaGraphOf() throws Exception {
"RETURN *",
assertResult);
}

@Test
public void testMetaStatsWithTwoDots() {
db.executeTransactionally("CREATE (n:`My:Label` {id:1})-[r:`http://www.w3.org/2000/01/rdf-schema#isDefinedBy` {alpha: 'beta'}]->(s:Another)");
TestUtil.testCall(db, "CALL apoc.meta.stats()", row -> {
assertEquals(map("My:Label", 1L, "Another", 1L), row.get("labels"));
assertEquals(2L, row.get("labelCount"));
assertEquals(map("http://www.w3.org/2000/01/rdf-schema#isDefinedBy", 1L), row.get("relTypesCount"));
assertEquals(2L, row.get("propertyKeyCount"));
assertEquals(map("()-[:http://www.w3.org/2000/01/rdf-schema#isDefinedBy]->(:Another)", 1L,
"()-[:http://www.w3.org/2000/01/rdf-schema#isDefinedBy]->()", 1L,
"(:My:Label)-[:http://www.w3.org/2000/01/rdf-schema#isDefinedBy]->()",1L),
row.get("relTypes"));
});

}
}

0 comments on commit 96a7ecd

Please sign in to comment.