Exception when adding `or` to query clause


#1

Hi, I asked this question a few days ago on the #datomic slack.

Sorry if this is the wrong venue to discuss this, I’m just puzzled by the behaviour I’m getting, what am I misunderstanding here?

This works:
q:

[:find ?id :in $ ?txt % :where (or [db-search $ ?txt ?id])]

args:

[{:db/alias "sql/db"} "test" [[[db-search ?db ?txt ?id] [(fulltext ?db :song/name ?txt) [[?id]]]]]]

Rewriting q as:

[:find ?id :in $1 ?txt % :where (or [db-search $1 ?txt ?id])]

throws which I’m not really understanding:

java.lang.Exception: processing rule: (q__922 ?id), message: processing clause: clojure.lang.LazySeq@ca35d41e, message: processing rule: [arule__737 ?txt ?id], message: processing clause: (db-search ?c__738 ?txt ?id), message: processing rule: [db-search ?db ?txt ?id], message: processing clause: {:argvars (?txt ?db), :fn #object[datomic.extensions$eval897$fn__898 0x3432ee74 "datomic.extensions$eval897$fn__898@3432ee74"], :clause [(fulltext ?db :song/name ?txt) [[?id]]], :binds [?id], :bind-type :rel, :needs-source false}, message: java.lang.NullPointerException

However this works:

[:find ?id :in $1 ?txt % :where [db-search $1 ?txt ?id]]

Now I want the or as I’m trying to query multiple databases and want to use the results together. I’m just trying to build it up in steps as that’s the way I’ve found to do this with minimal issues.

Sorry, I’ve been getting into Datomic again after a while being away from it for a few years and am trying to develop a new web service in it.

Thanks =)…


#2

As noted here, src-vars are not permitted within an or clause. The entire or clause must operate on one src-var.


#3

So how do you query multiple databases in this way? Or is it accepted practice to do multiple queries and manipulate the results on the other end?