Oh I got, thanks for pointing me to understand what is wrong. Actually my main case is to use different databases in OR-clauses but I see doc says: As with rules, *src-vars* are not currently supported within the clauses of *or* , but are supported on the *or* clause as a whole at top level.
and I found something on the internet: https://datomic.narkive.com/H6z769jM/multiple-databases-in-or and on the forum: Rules with multiple data sources?
Query I’m interesting is:
(d/q "[
:find [?user ...]
:in $ $someDb
:where
(or-join [?user]
(and
[$someDb _ :user/name ?externalName1]
[$ ?user :user/name.EN ?externalName1]
)
(and
[$someDb _ :user/name ?externalName2]
[$ ?user :user/name.EN ?externalName2]
)
)
]" (d/db conn) (d/db conn))
And looks like the only possible way is to rearrange query to:
(d/q "[
:find [?user ...]
:in $ $someDb
:where
[$someDb _ :user/name ?externalName1]
[$someDb _ :user/name ?externalName2]
(or-join [?user]
[?user :user/name.EN ?externalName1]
[?user :user/name.ES ?externalName2]
)
]" (d/db conn) (d/db conn))
But first case could be more preferable since if first statement from or is true then second part is not executed what is better from performance point