This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-03-15
Channels
- # aatree (1)
- # atlanta-clojurians (3)
- # beginners (112)
- # boot (4)
- # boot-dev (1)
- # bristol-clojurians (1)
- # cider (55)
- # cljs-dev (23)
- # cljsjs (1)
- # cljsrn (7)
- # clojars (24)
- # clojure (84)
- # clojure-brasil (1)
- # clojure-china (1)
- # clojure-italy (27)
- # clojure-norway (17)
- # clojure-romania (1)
- # clojure-spec (109)
- # clojure-uk (92)
- # clojurescript (94)
- # community-development (1)
- # core-matrix (1)
- # cursive (12)
- # datascript (1)
- # datomic (23)
- # figwheel (1)
- # fulcro (17)
- # hoplon (11)
- # jobs-discuss (3)
- # keechma (6)
- # lein-figwheel (4)
- # leiningen (79)
- # lumo (32)
- # mount (42)
- # off-topic (22)
- # onyx (13)
- # parinfer (30)
- # portkey (47)
- # powderkeg (1)
- # programming-beginners (24)
- # protorepl (3)
- # re-frame (16)
- # reagent (100)
- # ring-swagger (7)
- # shadow-cljs (134)
- # spacemacs (3)
- # sql (1)
- # tools-deps (48)
- # uncomplicate (1)
- # unrepl (14)
- # yada (1)
Is it possible to pass a pull pattern that contains some :default settings to query? If so - what’s the correct format? I get an error:
(d/q '[ :find (pull ?j query)
:in $ ?bin query
:where
[?j :job/bin ?bin]]
db
"1047470"
'[ (:job/fully-paid :default false) ])
datomic.impl.Exceptions$IllegalArgumentExceptionInfo: :db.error/invalid-attr-spec Cannot interpret as an attribute spec: (:job/fully-paid :default false) of class: class clojure.lang.PersistentList
@donmullen you might want to look at https://docs.datomic.com/cloud/query/query-data-reference.html#get-else and https://docs.datomic.com/cloud/query/query-pull.html#default-option
@marshall I’ve used get-else successfully in queries - but not :default in a pull pattern. Not sure what I’m missing. My example above seems to follow pattern in the docs :
[:artist/name (:artist/endYear :default "N/A")]
and in the day-of-datomic example: ;; default option
(d/pull db '[:artist/name (:artist/endYear :default 0)] mccartney)
@marshall I also got that error using d/pull as well which I was thinking would surely work - hmmm…
there is an older syntax for limit exprs, but the one you’re using there ^ is the newer one based on attr-with-options
(d/q '[:find [(pull ?e pattern) ...]
:in $ ?artist pattern
:where [?e :release/artists ?artist]]
db
led-zeppelin
'[(:release/name :as "Release")])
^ that gives:
[{"Release" "Houses of the Holy"} {"Release" "Immigrant Song / Hey Hey What Can I Do"} {"Release" "Immigrant Song / Hey Hey What Can I Do"} {"Release" "Heartbreaker / Bring It On Home"} {"Release" "Led Zeppelin III"} {"Release" "Whole Lotta Love / Living Loving Maid"} {"Release" "Led Zeppelin III"} {"Release" "Led Zeppelin III"} {"Release" "Led Zeppelin"} {"Release" "Led Zeppelin IV"} {"Release" "Led Zeppelin"} {"Release" "Led Zeppelin IV"} {"Release" "Led Zeppelin"} {"Release" "Led Zeppelin II"} {"Release" "Led Zeppelin II"} {"Release" "Led Zeppelin II"} {"Release" "Led Zeppelin II"}]
based on this example: https://github.com/Datomic/day-of-datomic/blob/master/tutorial/pull.clj#L113