Closed mortenschioler closed 11 months ago
I want to dereference tag enumeration entities as part of a pull expression. For example:
(pull db [{[:user/preferred-lang :xform #(:db/ident %)] [:db/ident]}] eid) ;; expected ;; => {:user/preferred-lang :lang/en} ;; actual ;; => {:user/preferred-lang {:db/ident :lang/en}}
Unfortunately, this doesn't work -- I've boiled it down to being because xforms don't get called for reference attributes:
(let [res (d/with (d/empty-db {:a-ref-attr {:db/valueType :db.type/ref}}) [[:db/add -1 :db/ident :a-tag] [:db/add -2 :a-ref-attr -1]]) ent-id (get-in res [:tempids -2]) db (:db-after res)] (d/pull db [[:a-ref-attr :xform (fn [%] (println "xform was called") 42)]] ent-id)) ;;; [SILENCE -- NO PRINT, and value is not 42 but #db{:id 1}] => {:a-ref-attr #:db{:id 1}}
Thanks! Should be fixed in 1.5.4
Wow, cool @tonsky! 💯 Thank you so much for your work on DataScript. Am using it in a POC with re-frame, after reading Into The Tar Pit, and am loving it.
I want to dereference tag enumeration entities as part of a pull expression. For example:
Unfortunately, this doesn't work -- I've boiled it down to being because xforms don't get called for reference attributes: