I have a hard time understanding why the following rule sometimes fail with a ClassCastException on the conj. Apparently ?parent-path is a Java array and not a IPersistentCollection.
This only happens in the transactor and not with d/with.
We would like to refer to nodes in a tree using their path from the root. I was hoping that a recursive rule like this would work:
I can send a minimal schema and query to reproduce my use-case if needed.
My expectation was that a vector would always be built at the bottom of the recursion. ?p would be bound to the result of (vector ?name). And then we conj this vector until we reach the leaf. Was my expectation correct? If not, where is it wrong?
you can’t force something to be a vector on the wire between peer and transactor
if you need a vector, you have to make it a vector after the wire
The encoding between peer and transactor doesn’t preserve Clojure vectors, which is why your example works using with (no wire) but doesn’t with a remote transactor (the vector becomes an array list).
When you pass in ?path in your query, it is bound to ?p in your rule, where the call to vector evaluates true, when the passed in path is an array list or a vector.
You would need to use an intermediate variable that you force into a new vector if you need the bottom of the rule to return a vector. I have provided a very small reproduction below (using an explicit array list):