All clauses in 'or' must use same set of vars?


#1

Hi,

when calling the below query in Java:
[:find ?e :in $ ?v1 ?v2 :where (or [?e :name ?v1][?e :name ?v2])]

I get an exception:
All clauses in ‘or’ must use same set of vars, had [#{?v1 ?e} #{?v2 ?e}]

Not sure I understand the error.
Any clue?


#2

Found the answer here:

Basically, you need to use an or-join and specify the list of joined inputs.

Not sure why Datomic is not able to automatically join using the global list of inputs…


#3

Glad you found the answer.

In your particular case though I would use collection binding.

[:find ?e :in $ [?v ...] :where [?e :name ?v]


#4

Seems much better indeed

Thanks!

Envoyé de mon iPhone


#5

Thanks for the tip, works, much simpler than or-join!