Nested upserts to the same entity by identity fails
Open
Nobody has claimed this yet.
- Dominant language
- Clojure
- Stars
- 5.8k
- Forks
- 318
- PR merge metrics
- No merged PRs in 30d
Description
Opening a separate issue based on comment at https://github.com/tonsky/datascript/issues/76#issuecomment-269110873
In order the following fails with Cannot add #datascript/Datom [1 :name "Ivan" true] because of unique constraint, but succeeds if you swap the order of keys in the map.
(deftest test-ref-upsert
(let [db (d/empty-db {:name {:db/unique :db.unique/identity}
:ref {:db/valueType :db.type/ref}})]
(are [tx res] (= res (tdc/all-datoms (d/db-with db tx)))
[(array-map :ref {:name "Ivan"} :name "Ivan")]
#{[1 :name "Ivan"]
[1 :ref 1]})))
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
Start by reproducing the test-ref-upsert case with the d/db-with transaction shown in the issue, then trace the nested identity upsert handling. Done means the transaction produces the expected datoms and succeeds regardless of the key order in the transaction map.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- clojure
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100