Don't replace keyword idents if the underlying field is itself :db.type/keyword.

This is necessary to assert new :db/ident datoms.
This commit is contained in:
Nick Alexander 2016-08-02 17:35:05 -07:00
parent a1e3158eac
commit 5d271454ac
2 changed files with 13 additions and 8 deletions

View file

@ -335,13 +335,13 @@
true
(recur (util/conj-in report [:entities] entity) entities))))))
(defn maybe-ident->entid [db [op & entity :as orig]]
;; TODO: use something faster than `into` here.
(->
(into [op] (for [field entity]
(get (idents db) field field))) ;; TODO: schema, not db.
;; (with-meta (get (meta orig) :source {:source orig}))
))
(defn maybe-ident->entid [db [op e a v tx :as orig]]
(let [e (get (idents db) e e) ;; TODO: use ident, entid here.
a (get (idents db) a a)
v (if (ds/kw? (schema db) a) ;; TODO: decide if this is best. We could also check for ref and numeric types.
v
(get (idents db) v v))]
[op e a v tx]))
(defrecord Transaction [db tempids entities])

View file

@ -24,6 +24,10 @@
:cljs [^boolean ref?]) [schema attr]
(is-attr? schema attr :db.type/ref))
(defn #?@(:clj [^Boolean kw?]
:cljs [^boolean kw?]) [schema attr]
(is-attr? schema attr :db.type/keyword))
(defn #?@(:clj [^Boolean component?]
:cljs [^boolean component?]) [schema attr]
(is-attr? schema attr :db/isComponent))
@ -59,7 +63,8 @@
(= v :db.cardinality/many) [:db.cardinality/many]
(= v :db.unique/identity) [:db/unique :db.unique/identity :db/index]
(= v :db.unique/value) [:db/unique :db.unique/value :db/index]
(= [k v] [:db/index true]) [:db/index]))
(= [k v] [:db/index true]) [:db/index]
(= k :db/valueType) [v]))
(defn- multimap [e m]
(reduce