tonsky / datascript

Immutable database and Datalog query engine for Clojure, ClojureScript and JS
Eclipse Public License 1.0
5.45k stars 304 forks source link

tempid conflict-resolve exception #472

Closed RCmerci closed 2 months ago

RCmerci commented 3 months ago

this piece of code will throw a Conflicting upsert exception:

(def xdb1 (d/empty-db {:xxx {:db/valueType :db.type/ref}}))
(def xdb2 (d/db-with xdb1 [{:db/ident :ident1} {:db/ident :ident2}]))
(def xdb3 (d/db-with xdb2 [[:db/add 32 :xxx "120"]
                           [:db/add 3333 :xxx "119"]
                           {:db/id "119" :db/ident :ident1}
                           {:db/id "120" :db/ident :ident2}]))
;;; Conflicting upsert: "120" resolves both to 2 and 3

I'm not sure if this is due to incorrect usage of tempid or if it's a bug.

tonsky commented 3 months ago

Yeah it’s a bug

tonsky commented 2 months ago

Fixed and pushed as 1.7.0