Skip to content

Commit

Permalink
Fix null pointer exception when contains? is called with an entity.
Browse files Browse the repository at this point in the history
  • Loading branch information
lynaghk authored and tonsky committed Sep 16, 2015
1 parent a7d7c89 commit 4951662
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# WIP

- Fix null pointer exception when `contains?` is called with an entity (PR #114, thx [Kevin Lynagh](https://github.com/lynaghk))

# 0.12.1

- `db-init` respects `:db/index` property
Expand Down
2 changes: 1 addition & 1 deletion src/datascript/impl/entity.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@

clojure.lang.Associative
(equiv [e o] (equiv-entity e o))
(containsKey [e k] (lookup-entity e k))
(containsKey [e k] (not= ::nf (lookup-entity e k ::nf)))
(entryAt [e k] (some->> (lookup-entity e k) (clojure.lang.MapEntry. k)))

(empty [e] (throw (UnsupportedOperationException.)))
Expand Down
2 changes: 2 additions & 0 deletions test/datascript/test/entity.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
(is (= (e :name) "Ivan")) ; IFn form
(is (= (:age e) 19))
(is (= (:aka e) #{"X" "Y"}))
(is (= true (contains? e :age)))
(is (= false (contains? e :not-found)))
(is (= (into {} e)
{:name "Ivan", :age 19, :aka #{"X" "Y"}}))
(is (= (into {} (d/entity db 1))
Expand Down

0 comments on commit 4951662

Please sign in to comment.