-
-
Notifications
You must be signed in to change notification settings - Fork 96
Description
ArcadeDB Version: master (444da9f) / 21.10.1
JDK Version: 11.0.13
Actual behavior
-
In CypherQueryEngine collection values in map structure(vertices/edges) will not be sanitized according to the name schema of Arcade DB.
e.g.id -> @rid , label -> @type -
In PostCommandHandler the collection values are not handled anymore, because collection values of kind
Map are not handled in com.arcadedb.serializer.JsonSerializer.serializeResult(Result).
Due that fact a RID Object of a map result is not handled and will be serialized not as a String.
The serialization will break due circular references in RID.
Expected behavior
Sanitize all values in CypherQueryEngine and maybe wrap nested Maps as a Result in Lists to be handled again in
PostCommandHandler. But it depends on the interface definition of QueryEngine.command(final String query, final Map<String, Object> parameters) and the returned ReultSet and the values that should returned: plain Map, Result, Element,...
Steps to reproduce
Simple parent with multiple child relationship with the cypher collect function:
eg. match(p:parent)--(c:child) return p, collect(c)
I can provide a PR with test & solution proposal
This is test setup to get the invalid results from query. The 'childs' projection will not be transformed.
@Test
public void verifyProjectionWithCollectFunction() throws ExecutionException, InterruptedException {
final ArcadeGraph graph = ArcadeGraph.open(DB_PATH);
try (Database database = graph.getDatabase()) {
database.transaction(() -> {
Schema schema = database.getSchema();
schema.getOrCreateVertexType("V");
schema.getOrCreateEdgeType("E");
MutableVertex v1 = database.newVertex("V").save();
MutableVertex v2 = database.newVertex("V").save();
MutableVertex v3 = database.newVertex("V").save();
v1.newEdge("E", v2, true);
v1.newEdge("E", v3, true);
try (ResultSet query = database.query("cypher",
"match(parent:V)-[e:E]-(child:V) where id(parent) = $p return parent as parent, collect(child) as childs", "p",
v1.getIdentity())) {
}
});
} finally {
graph.drop();
}
}