This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-07-22
Channels
- # beginners (20)
- # boot (5)
- # cider (14)
- # cljs-dev (15)
- # cljsrn (1)
- # clojure (81)
- # clojure-greece (7)
- # clojure-italy (17)
- # clojure-spec (5)
- # clojure-uk (15)
- # clojurescript (143)
- # data-science (1)
- # datomic (7)
- # defnpodcast (4)
- # docs (1)
- # figwheel-main (1)
- # fulcro (37)
- # graphql (1)
- # hoplon (3)
- # luminus (1)
- # reitit (5)
- # shadow-cljs (10)
- # spacemacs (5)
- # tools-deps (14)
- # vim (7)
(d/q {:query '{:find [?id ?title (pull ?id [:journal/id])]
:where [[?id :journal/title ?title]]}
:args [(d/db conn)]})
`
Gives me the following error:
ExceptionInfo processing rule: (q__1114 ?id ?title ?id), message: processing clause: [?id :journal/title ?title], message: java.lang.ArrayIndexOutOfBoundsException: 2 clojure.core/ex-info (core.clj:4739)
You can only have each entity once in a find expression. In your original example, you have ?id
and the pull on ?id
. You could pull [:journal/title :db/id]
if you want to pull both.
Ah, yes, I can see ?id
appearing twice there. java.lang.ArrayIndexOutOfBoundsException
threw me off. Pull looks like a function, so intuition suggests that ?id
would be consumed by it and of no concern for the surrounding bits. There’s clearly some magic going on here.
Dropping the initial ?id
in the :find
clause works fine though:
(d/q {:query '{:find [?title (pull ?id [:journal/id])]
:where [[?id :journal/title ?title]]}
:args [(d/db conn)]}
[["International Bulletin of Mission Research"
{:id [{:identity/type "publisher-id",
:identity/value "IBM",
:db/id 22918220369363020}
{:identity/type "hwp",
:identity/value "spibm",
:db/id 22918220369363024}]}]]