dscarpetti / codax

An idiomatic transactional embedded database for clojure
Eclipse Public License 1.0
179 stars 9 forks source link

Issue in with-write-transaction #10

Closed dbushenko closed 7 years ago

dbushenko commented 7 years ago

I'm doing like this:

(defn init-db [ db ] (c/with-write-transaction [db tx] (when-not (c/get-at tx [:counters :user-id]) (c/assoc-at tx [:counters :user-id] 1))))

This is for the one-time DB initialization. As you see, if the DB was already initialized, the body of the when-not will not be evaluated, nothing is written to DB. This leads to NullPointerException clojure.lang.RT.longCast (RT.java:1259)