Fork me on GitHub

is there something like get-else but for relations?


basically, I need to integrate some external data into a query. The data is a vector of tuples with an id and the constant true. I know I can include it via :in $ [[?id ?val]] but I need to default ?val to false for all the ?id not included. 😕


interesting. if I turn it into a map instead, and refer to it as :in $ $1 and use [(get $1 ?id false) ?val] that works which is unexpectedly…good?

Ben Kamphaus20:03:43

@actsasgeek: You shouldn’t need to turn it into a map or invoke Clojure functions, but you should be using the $ to use the tuples as a src-var as opposed to the relational binding if you want to treat it as a data source (which is what get-else would require).


but get-else also requires an attribute and I’m not sure what that would be…an index?

Ben Kamphaus21:03:37

It’s tailored for a datom, that’s true, (i.e. EAV…) , so if the data isn’t in that form, the options are to use your own function, which appears to be working in your other example (so maybe fine to use that), or structure the data into a datom like structure which would work with the builtin get-else or other provided functions.


so would transforming [[?id ?val]] into something like [[?id :my/val ?val]] have worked? Or is there more to it than that?


(or better yet, just generate the second form at the start)