I have a hard time understanding why the following rule sometimes fail with a ClassCastException on the
?parent-path is a Java array and not a IPersistentCollection.
This only happens in the transactor and not 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:
(def node-path '[;; node without a parent [(node-path ?n ?p) [?n :node/name ?name] [(missing? $ ?n :node/parent)] [(vector ?name) ?p]] ;; node with a parent [(node-path ?n ?p) [?n :node/name ?name] [?n :node/parent ?parent] (node-path ?parent ?parent-path) [(conj ?parent-path ?name) ?p]]])
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?
Thanks a lot for your help.