tonsky / datascript

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

Data retracted incorrectly in CLJS #404

Closed ash14 closed 3 years ago

ash14 commented 3 years ago

It seems that the implementation of value-compare using hashcodes can lead to some very surprising behaviour:

Compare CLJ:

(let [conn (d/create-conn)]
  (d/transact! conn [{:user/age 42.5}])
  (:tx-data (d/transact! conn [[:db/retract 1 :user/age 42]])) ; => []
  (d/touch (d/entity (d/db conn) 1))) ; => {:user/age 42.5, :db/id 1}

With CLJS:

(let [conn (d/create-conn)]
  (d/transact! conn [{:user/age 42.5}])
  (:tx-data (d/transact! conn [[:db/retract 1 :user/age 42]])) ; => [#datascript/Datom[1 :user/age 42.5 536870914 false]]
  (d/touch (d/entity (d/db conn) 1))) ; => {:db/id 1}

In this case 42 should not be considered equal to 42.5

tonsky commented 3 years ago

Thank you, that’s nasty. Fixed in 1.2.7

ash14 commented 3 years ago

Thanks for the quick response. Confirmed fixed when using 1.2.7 from clojars but the change isn't in this repo? https://github.com/tonsky/datascript/compare/1.2.6...1.2.7

tonsky commented 3 years ago

My bad. Looks like I deployed from a local copy and forgot to commit. Republished properly as 1.2.8