This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-02-08
Channels
- # announcements (14)
- # babashka (12)
- # beginners (140)
- # calva (2)
- # cider (22)
- # clj-commons (14)
- # clj-kondo (49)
- # cljdoc (34)
- # clojure (92)
- # clojure-europe (41)
- # clojure-france (2)
- # clojure-new-zealand (2)
- # clojure-nl (2)
- # clojure-norway (60)
- # clojure-uk (17)
- # clojured (2)
- # clojurescript (7)
- # community-development (3)
- # conjure (2)
- # cryogen (13)
- # cursive (4)
- # data-oriented-programming (2)
- # datahike (5)
- # datomic (12)
- # defnpodcast (10)
- # events (2)
- # fulcro (20)
- # gratitude (3)
- # honeysql (4)
- # introduce-yourself (3)
- # jobs (10)
- # lsp (58)
- # malli (12)
- # missionary (19)
- # off-topic (8)
- # pathom (18)
- # podcasts-discuss (1)
- # polylith (41)
- # releases (1)
- # remote-jobs (3)
- # shadow-cljs (52)
- # spacemacs (1)
- # sql (37)
- # xtdb (19)
Hi all. I'm having a problem querying through time! Any help much appreciated.
Say I want to pass two databases to some query. One is the current database $
and one is before $before
. This seems to work for some simple clauses:
[$before ?version :vulnerability.advisory.version/vulnerable-range ?range]
but using or-join
for example:
(or-join [?version ?range]
[$before ?version :vulnerability.advisory.version/vulnerable-range ?range])
we get an error:
{:cognitect.anomalies/category :cognitect.anomalies/incorrect,
:cognitect.anomalies/message
"processing clause: [$before ?version :vulnerability.advisory.version/vulnerable-range ?range], message: Cannot resolve key: $before"}
I've tried passing the database in arguments to the or-join, but the error is similar:
{:cognitect.anomalies/category :cognitect.anomalies/incorrect,
:cognitect.anomalies/message
"processing clause: [$before ?version ?range], message: Cannot resolve key: $before"}
Am I doing something wrong here? Is there another way to pass databases around?According to the documentation the syntax for or-join is: or-join-clause = [ src-var? 'or-join' rule-vars (clause | and-clause)+ ]
so maybe try
($before or-join [?version ?range]
[?version :vulnerability.advisory.version/vulnerable-range ?range])
if you name your rule, you can pass it before the rule name:
($my-database rule ?arg ?arg2 ?arg2)
but you can never pass more than one database value to a rule
(the syntax is available here: https://docs.datomic.com/on-prem/query/query.html#query )
@UDF11HLKC thanks, but I'm not using a rule here (at least not one I can control)
You are, or-join is just an anonymous rule; so the same limitation counts for the syntax Linus shared
Thanks @UQY3M3F6D - I found similar docs for cloud here: https://docs.datomic.com/cloud/query/query-data-reference.html#or-join
The problem is that I need a different database for different clauses of the or-join - hence my attempt there. Sounds like I need to create my own function to do this.
Yes, I think that will need a separate function or separate queries.
Found a reference to the same issue here: https://forum.datomic.com/t/database-cant-be-passed-explicitly-for-or-or-join-clauses/1373/5