tonsky / datascript

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

Error after retracting data #9

Closed EwenG closed 10 years ago

EwenG commented 10 years ago

Hello,

I have an error while querying a database with retracted data.

Here is the code I am executing with datascript 0.1.4:

(let [db (-> (ds/empty-db {:aka {:db/cardinality :db.cardinality/many}})
               (ds/with [[:db/add 1 :name "Ivan"]])
               (ds/with [[:db/add 1 :name "Petr"]])
               (ds/with [[:db/add 1 :aka "Devil"]])
               (ds/with [[:db/add 1 :aka "Tupen"]]))]
    (ds/entity db 1))

=> {:db/id 1, :aka ("Devil" "Tupen"), :name "Petr"}

(let [db (-> (ds/empty-db {:aka {:db/cardinality :db.cardinality/many}})
               (ds/with [[:db/add 1 :name "Ivan"]])
               (ds/with [[:db/add 1 :name "Petr"]])
               (ds/with [[:db/add 1 :aka "Devil"]])
               (ds/with [[:db/add 1 :aka "Tupen"]]))]
    (let [db (-> db
                 (ds/with [[:db/retract 1 :name "Petr"]])
                 (ds/with [[:db/retract 1 :aka "Devil"]]))]
      (ds/entity db 1)))

=> TypeError: Cannot read property 'v' of null

tonsky commented 10 years ago

Turned out to be a bug in entity call, thx!