This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-07-17
Channels
- # babashka (9)
- # beginners (10)
- # calva (10)
- # cider (2)
- # clojure (19)
- # clojure-denver (11)
- # clojure-europe (13)
- # clojure-nl (1)
- # clojure-norway (17)
- # clojure-uk (3)
- # clojurescript (30)
- # conjure (1)
- # core-typed (15)
- # cursive (26)
- # data-science (4)
- # datomic (5)
- # emacs (6)
- # events (1)
- # fulcro (14)
- # honeysql (15)
- # hyperfiddle (51)
- # lsp (1)
- # obb (36)
- # off-topic (7)
- # polylith (4)
- # practicalli (12)
- # reitit (20)
- # shadow-cljs (25)
- # xtdb (4)
running into an error when im trying to parameterize a key in the :where
clause of an XTDBv2 datalog query
evaluating this results in a status: 400
error (full err message in thread)
;; Breakies :'^(
(defn find-by [conn k v]
(xt/q conn
['{:find [contact]
:in [k v]
:where [($ :contact [{k v
:xt/* contact}])]}
k v]))
(find-by xtdb-conn :xt/id 17)
whereas hard-coding the key returns fine
(defn find-by-id [conn v]
(xt/q conn
['{:find [contact]
:in [v]
:where [($ :contact [{:xt/id v
:xt/* contact}])]}
v]))
(find-by-id xtdb-conn 17)
are parameterized keys not kosher? or is there something else I'm doing wrong?Full error message:
; Error in thread Thread[nREPL-session-3331506f-6cbc-4440-99c8-d4ee44272f94,5,main]
; Execution error (ExceptionInfo) at juxt.clojars-mirrors.hato.v0v8v2.hato.middleware/exceptions-response (middleware.clj:149).
; status: 400
yep, afraid we won't be supporting parameterised keys in v2 either. try something like this?
(defn find-by [conn k v]
(xt/q conn
[{:find '[contact]
:in '[v]
:where [(list '$ :contact [{k 'v, :xt/* 'contact}])]}
v]))
ahhhh okay, I really thought I was missing something- that helps a lot, thank you!
🙏 2