juji-io / datalevin

A simple, fast and versatile Datalog database
https://github.com/juji-io/datalevin
Eclipse Public License 1.0
1.07k stars 60 forks source link

Entity comparison seems to be broken #191

Closed den1k closed 1 year ago

den1k commented 1 year ago
(require '[datalevin.core :as d])

(def test-conn
  (d/create-conn
    nil
    {:id {:db/unique    :db.unique/identity
          :db/valueType :db.type/string}}))

(d/transact! test-conn [{:id "ent-a"}])
;=> {:datoms-transacted 1}

(d/transact! test-conn [{:id       "ent-b"
                         :some-edn {:entity (d/entity @test-conn [:id "ent-a"])}}])
;=> {:datoms-transacted 2}

(d/transact! test-conn [{:id "ent-b"
                         :some-edn :replace}])
; => 
;Execution error (NullPointerException) at datalevin.entity/ent->map (entity.cljc:315).
;Cannot read field "store" because "db" is null
den1k commented 1 year ago

The issue seems to be on thawing when map->ent returns nil here https://github.com/juji-io/datalevin/blob/master/src/datalevin/entity.cljc#L328