dynamicarangodbwith-statementaqlgraph-traversal

Dynamic WITH statement


Is it possible to dynamically construct a WITH statement? I have to do a graph traversal, but I don't know in advance which collections contain the graph nodes. I have tried to create the statement dynamically, but I keep getting strange errors that don't seem to have anything to do with that. I collect all the collection names from the document handles in the query and I create a comma separated list of collection names that I dynamically inject into the query.


Solution

  • For cluster deployments, it is necessary to declare the possibly involved collections upfront when you use graph traversals. More specifically:

    Calculating the collections for WITH at runtime isn't possible as that is too late for the query engine. It needs to prepare a cluster query with this knowledge for deterministic locking, which is necessary to avoid deadlocks, and there might also be some setup for traversals that requires knowledge about the involved collections.