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

Datoms that differ only by :added key are considered equal #220

Open tomconnors opened 7 years ago

tomconnors commented 7 years ago
(= (datascript.core/datom 1 :a "v" 500 true) (datascript.core/datom 1 :a "v" 500 false))
;; => true

Is this expected?

tonsky commented 7 years ago

I don’t remember at this point. What does Datomic do?

rauhs commented 7 years ago

Datomic doesn't make them equal unless the T is also equal:

(:import (datomic.db Datum))
(= 
  (Datum. 0 5 "f" 1)
  (Datum. 0 5 "f" 3))
;; => false

Notable: It uses the :db/id of the attribute in the Datom. And they use the lowest bit to encode assertion vs retraction.