Relative Content

Tag Archive for recursionclojurenestedhstoreltree

Trying to create a nested map in Clojure from ltree data causes Posgres to throw misleading errors

I am trying to create a list of maps with :node_name, :children and :is_leaf keys. When children is not nil, it would also create a nested map with the same keys. Things work if the :children key is just a simple list of names of the nodes where the nesting level is nlevel(current_node) + 1, but things start to break when I try to recursively create a nested map of children for each node that is not a leaf node instead. On a side note I’m also looking for ways to reduce the number of times the query is evaluated within the recursive calls. My data flow that works is the following: