Should get-else allow a lookup (ie a vector of unique attribute + value) in the eid field? The datomic docs suggest any entity identifier is allowed https://docs.datomic.com/cloud/query/query-data-reference.html#get-else
(d/q
'[:find ?maybe
:in $ ?lookup
:where [(get-else $ ?lookup ::number 0) ?maybe]]
(d/db-with (d/empty-db {::id {:db/unique :db.unique/identity}})
[{::id 123}])
[::id 123])
Results in:
ClassCastException class clojure.lang.PersistentVector cannot be cast to class java.lang.Number...
I can open an issue or possibly attempt a fixDoes it work if you put vector in the query, not in the parameter?
(d/q
'[:find ?maybe
:in $ ?lookup
:where [(get-else $ [::id ?lookup] ::number 0) ?maybe]]
(d/db-with (d/empty-db {::id {:db/unique :db.unique/identity}})
[{::id 123}])
123)
Seems like a reasonable request either wayOpen an issue, or, better else, PR :)
Same error, and will do!
Issue opened: https://github.com/tonsky/datascript/issues/445 I'll take a stab at a PR soon