Skip to content

Commit b28f657

Browse files
committed
add unique constraint back for tail check
1 parent 6ebfce8 commit b28f657

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/datascript/storage.cljs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,15 @@
158158
:max-eid max-eid
159159
:max-tx max-tx})]
160160
(remember-db db)
161-
[db (mapv #(mapv (fn [[e a v tx]] (db/datom e a v tx)) %)
161+
[db (mapv #(keep (fn [[e a v tx]]
162+
;; TODO: do we still need this?
163+
;; fix unique constraint
164+
(let [datoms (db/-datoms db :eavt e a v nil)
165+
datom-exists? (some (fn [datom] (= tx (:tx datom))) datoms)
166+
;; retracted tx < 0
167+
added? (> tx 0)]
168+
(when-not (and datom-exists? added?)
169+
(db/datom e a v tx))))%)
162170
tail)]))))
163171

164172
(defn db-with-tail [db tail]

0 commit comments

Comments
 (0)