This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-07-23
Channels
- # announcements (1)
- # aws (13)
- # babashka (31)
- # beginners (102)
- # calva (46)
- # cider (16)
- # clj-kondo (1)
- # cljs-dev (3)
- # clojars (1)
- # clojure (396)
- # clojure-argentina (1)
- # clojure-australia (4)
- # clojure-europe (64)
- # clojure-nl (2)
- # clojure-uk (8)
- # clojurescript (20)
- # conjure (5)
- # cursive (4)
- # datomic (15)
- # emacs (48)
- # graalvm (69)
- # graalvm-mobile (1)
- # jobs (4)
- # jobs-rus (1)
- # lsp (6)
- # malli (15)
- # meander (2)
- # observability (11)
- # off-topic (10)
- # pathom (2)
- # portal (4)
- # re-frame (19)
- # reitit (1)
- # remote-jobs (3)
- # sci (1)
- # shadow-cljs (51)
- # tools-deps (11)
- # vim (12)
- # xtdb (13)
Hello all, what is the problem with that?
(d/q '[:find ?e ?id :where [?e :user/id ?id]] (-> @system :system.component.datomic/db))
; Execution error (Exceptions$IllegalArgumentExceptionInfo) at datomic.error/arg (error.clj:57).
; :db.error/invalid-data-source Nil or missing data source. Did you forget to pass a database argument?
#:datomic{:conn #object[datomic.peer.LocalConnection 0x6ae42d2d "datomic.peer.LocalConnection@6ae42d2d"]} <- for (-> @system stuff ...
How does one exclude values in a collection binding? this does not work:
(db/q '[:find [?m ...]
:in $ [?ignore-ids ...]
:where
[?m :mom-rec-id ?mid]
(not [?m :mom-rec-id ?ignore-ids])]
#{"ignored" "ids"})
Have you tried a contains?
predicate like this instead of the not clause: [(clojure.core/contains? ?ignore-ids ?mid)]
?
yes using functions works, I also passed in the complement
ed set and used it as a function
hmm, I think you want to use Datalog-native unification like this then
(db/q '[:find [?m ...]
:in $ [?ignore-ids ...]
:where
[?m :mom-rec-id ?mid]
[(!= ?m ?ignore-ids)]
#{"ignored" "ids"})
I had a issue with this kind of queries and end up writing:
:in $ ?ignore
:where
[?m :mom-rec-id ?mid]
[(contains? ?ignore ?mid) ?q]
[(ground false) ?q]
https://gist.github.com/souenzzo/c7b5a5434d4c04efcc58802c81b46023@U899JBRPF tried that and it didn’t work for me
oh, yeah, maybe datascript doesn't support it...I was looking at Crux's tests for inspiration 😅 https://github.com/juxt/crux/blob/065db71c9f6f4c3a3c2d2eb75916bb15c719f75b/crux-test/test/crux/query_test.clj#L1008-L1011 - I can't see an equivalent test in datascript's suite, and looking at the source it seems datascript maps !=
to not=
which is not really the same thing imo
I guess that kind of unification logic is ~impractical without a query planner
(sorry for the noise!)