This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-02-16
Channels
- # announcements (18)
- # architecture (12)
- # babashka (20)
- # beginners (32)
- # biff (21)
- # calva (81)
- # clerk (6)
- # clj-kondo (16)
- # clj-otel (5)
- # cljsrn (8)
- # clojure (94)
- # clojure-austin (1)
- # clojure-australia (1)
- # clojure-europe (68)
- # clojure-nl (2)
- # clojure-norway (6)
- # clojure-uk (2)
- # clojurescript (13)
- # conjure (1)
- # core-logic (1)
- # cursive (7)
- # data-science (2)
- # datahike (3)
- # datomic (12)
- # emacs (33)
- # etaoin (1)
- # fulcro (8)
- # graalvm (2)
- # graphql (1)
- # honeysql (1)
- # hyperfiddle (97)
- # improve-getting-started (40)
- # jobs (2)
- # jobs-discuss (12)
- # lsp (9)
- # membrane (6)
- # nbb (2)
- # off-topic (16)
- # portal (6)
- # re-frame (2)
- # reagent (3)
- # releases (2)
- # remote-jobs (1)
- # tools-deps (7)
- # xtdb (38)
Is there any way within a query to propagate the current rule environment (`%`) into it? I am frequently in a situation where I need a subquery for an existence check (i.e. “any of these values may match”) but need a rule in the subquery. E.g. a rule like
[(rule-any-matches ?e ?test-values)
[(q '[:find ?e
:in $ [?test-value ...]
:where (some-other-rule ?e ?test-value)] $ ?test-values) [[?_ignored]]]]
If I mention % I get an exception; if I don’t, the rule seems to silently just not work
Yes, pass the rule to the outer query as something like rule
instead of %
, then pass that to the subquery as %
hm, it’s kinda annoying that datasources are ambient in rules and I can’t ever have more than one of them (and often would like it); yet rule sets are not, I would never want more than one, and yet I have to manage its propagation myself?
My google-fu seems to be failing me. Does anyone happen to know where in the docs the behavior of a pull reverse lookup + isComponent=true + cardinality=one is specified as returning the result not in a vector? e.g.,
;; schema
{:db/ident :not-a-component
:db/cardinality :db.cardinality/one
:db/valueType :db.type/ref}
{:db/ident :a-component
:db/cardinality :db.cardinality/one
:db/valueType :db.type/ref
:db/isComponent true}
(d/pull db
'[{:_not-a-component [:title]}]
[:id "a"])
=> {:_not-a-component [{:title "foo"}]}
(d/pull db
'[{:_a-component [:title]}]
[:id "a"])
=> {:_a-component {:title "foo"}}
Maybe it was only in old docs describing the entity map api, before client+pull became the “preferred” apis
I’m also not sure I ever read it anywhere; it’s just one of those datomic trivia things at this point
It’s not mentioned here either: https://docs.datomic.com/on-prem/schema/schema.html#component
Haha. I vaguely remember a blog post discussing components that may have mentioned it. I recall the blog content would slide up from the bottom of the screen haha.
pretty impressed.. which I guess can be inferred from: https://docs.datomic.com/on-prem/query/pull.html#component-defaults and https://docs.datomic.com/on-prem/query/pull.html#multiple-results