Skip to content

Commit

Permalink
Do not treat maps as coll values for :db.cardinality/many attributes (c…
Browse files Browse the repository at this point in the history
…loses #16)
  • Loading branch information
tonsky committed Aug 26, 2014
1 parent c6c59ad commit 1d842bd
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

- Optimized speed of DB’s `equiv` and `hash`, Datom’s `hash`
- Entity’s `touch` call accessible through `datascript` namespace
- Accept sets in entity maps as values for `:db.cardinality/many` attributes

# 0.3.0

Expand Down
3 changes: 2 additions & 1 deletion src/datascript/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,8 @@
(defn- explode [db entity]
(let [eid (:db/id entity)]
(for [[a vs] (dissoc entity :db/id)
v (if (and (coll? vs)
v (if (and (or (array? vs) (coll? vs))
(not (map? vs))
(multival? db a))
vs [vs])]
[:db/add eid a v])))
Expand Down
3 changes: 2 additions & 1 deletion test/test/datascript.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,8 @@
;;Test that explode works properly with vectors, sets, and lists.
(doseq [coll [["Devil" "Tupen"]
#{"Devil" "Tupen"}
'("Devil" "Tupen")]]
'("Devil" "Tupen")
#js ["Devil" "Tupen"]]]
(let [conn (d/create-conn { :aka { :db/cardinality :db.cardinality/many }
:also { :db/cardinality :db.cardinality/many} })]
(d/transact! conn [{:db/id -1
Expand Down

0 comments on commit 1d842bd

Please sign in to comment.