get-else on :db.cardinality/many doesn't work
Nobody has claimed this yet.
- Dominant language
- Clojure
- Stars
- 5.8k
- Forks
- 318
- PR merge metrics
- No merged PRs in 30d
Description
Using get-else terminates even if there are more results to be find when applied on a :db.cardinality/many attribute. This is different from Datomic, which returns every match even when get-else is used.
Below is a minimal example and the result when not using get-else, which is also the expected result. I'm using Datascript 0.15.0 on Clojure 1.8.0.
I have not tried reproducing the issue in ClojureScript.
(require '[datascript.core :as d])
(let [schema {:aka {:db/cardinality :db.cardinality/many}}
conn (d/create-conn schema)]
(d/transact! conn [ { :db/id -1
:name "Maksim"
:aka ["Maks Otto von Stirlitz", "Jack Ryan"] } ])
(d/q '[:find ?name ?aka
:where
[?e :name ?name]
[(get-else $ ?e :aka "N/A") ?aka] ]
@conn))
;; NOT EXPECTED:
;; => #{["Maksim" "Jack Ryan"]}
(let [schema {:aka {:db/cardinality :db.cardinality/many}}
conn (d/create-conn schema)]
(d/transact! conn [ { :db/id -1
:name "Maksim"
:aka ["Maks Otto von Stirlitz", "Jack Ryan"] } ])
(d/q '[:find ?name ?aka
:where
[?e :name ?name]
[?e :aka ?aka] ]
@conn))
;; EXPECTED (even with get-else):
;; => #{["Maksim" "Jack Ryan"] ["Maksim" "Maks Otto von Stirlitz"]}
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The report is centered on d/q with get-else over a :db.cardinality/many attribute, using d/create-conn and d/transact!. First run the supplied Clojure reproduction and compare it with the direct [?e :aka ?aka] query; done means get-else returns both aliases as shown in the expected result.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- clojure
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100