File tree Expand file tree Collapse file tree 2 files changed +21
-19
lines changed
Expand file tree Collapse file tree 2 files changed +21
-19
lines changed Original file line number Diff line number Diff line change 44- Added ` contains? ` to built-ins (#211 )
55- Fixed handling of false values in entity cache (PR #198 , thx [ Brandon Bloom] ( https://github.com/brandonbloom ) )
66- Fixed issue when string values were interpreted as lookup refs (#214 )
7+ - Speed up rschema calculation (#192 , thx [ Andre R.] ( https://github.com/rauhs ) )
78
89# 0.15.5
910
Original file line number Diff line number Diff line change 513513; ; ----------------------------------------------------------------------------
514514
515515(defn attr->properties [k v]
516- (cond
517- (= [k v] [:db/isComponent true ]) [:db/isComponent ]
518- (= v :db.type/ref ) [:db.type/ref :db/index ]
519- (= v :db.cardinality/many ) [:db.cardinality/many ]
520- (= v :db.unique/identity ) [:db/unique :db.unique/identity :db/index ]
521- (= v :db.unique/value ) [:db/unique :db.unique/value :db/index ]
522- (= [k v] [:db/index true ]) [:db/index ]))
523-
524- (defn- multimap [e m]
525- (reduce
526- (fn [acc [k v]]
527- (update-in acc [k] (fnil conj e) v))
528- {} m))
516+ (case v
517+ :db.unique/identity [:db/unique :db.unique/identity :db/index ]
518+ :db.unique/value [:db/unique :db.unique/value :db/index ]
519+ :db.cardinality/many [:db.cardinality/many ]
520+ :db.type/ref [:db.type/ref :db/index ]
521+ (when (true ? v)
522+ (case k
523+ :db/isComponent [:db/isComponent ]
524+ :db/index [:db/index ]
525+ []))))
529526
530527(defn- rschema [schema]
531- (->>
532- (for [[a kv] schema
533- [k v] kv
534- prop (attr->properties k v)]
535- [prop a])
536- (multimap #{})))
528+ (reduce-kv
529+ (fn [m attr keys->values]
530+ (reduce-kv
531+ (fn [m key value]
532+ (reduce
533+ (fn [m prop]
534+ (assoc m prop (conj (get m prop #{}) attr)))
535+ m (attr->properties key value)))
536+ m keys->values))
537+ {} schema))
537538
538539(defn- validate-schema-key [a k v expected]
539540 (when-not (or (nil? v)
You can’t perform that action at this time.
0 commit comments