This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-05-17
Channels
- # announcements (1)
- # beginners (44)
- # calva (20)
- # cljs-dev (22)
- # cljsrn (5)
- # clojars (24)
- # clojure (33)
- # clojure-europe (36)
- # clojure-filipino (1)
- # clojure-indonesia (1)
- # clojure-my (1)
- # clojure-nl (2)
- # clojure-sg (2)
- # clojure-uk (8)
- # clojurescript (73)
- # code-reviews (21)
- # conjure (13)
- # cursive (46)
- # datahike (16)
- # datomic (5)
- # depstar (1)
- # graalvm (7)
- # honeysql (22)
- # jobs (2)
- # jobs-discuss (2)
- # kaocha (3)
- # luminus (2)
- # malli (2)
- # nrepl (17)
- # off-topic (46)
- # pathom (14)
- # re-frame (7)
- # remote-jobs (1)
- # sci (8)
- # shadow-cljs (33)
- # sql (14)
- # vim (48)
- # xtdb (1)
Any tips on how to express:
SELECT ARRAY[1,2] && foo;
in honeysql (still on v1 in our production app)? The left array is from values from input, the other array foo
is from a tableand now the [:&& included-uuids :tzdb.tag_uuids]
part: can I generate the &&
as an operator instead of a function?
(sorry, this is probblay in the docs somewhere, but I have trouble finding it š )
I did this:
(defmethod hf/fn-handler "&&" [op & args]
(let [args (map hf/to-sql args)]
(hf/paren-wrap (str/join (str " " op " ") args))))
Sounds like youāve solved the problem? Which DB is that for? ||
is a variadic infix operator in V2 for string concatenation so Iām a bit surprised to see &&
ā what does it mean?
@seancorfield this is an array operator in postgresql.
array[1,2,3] && array[1,2,3,4]
means all the left elements must occur in the right elementsThatās easy in HoneySQL v2 but I think fn-handler
is the right approach in v1.
In v2 itās (sql/register-op! :&& :variadic true)
and youāre off to the races. But Iāll go ahead and add &&
as a built-in for the next v2 version anyway.
Yup. develop has that change. Itāll be in RC 3 or āgoldā, whichever comes next.
if I have an array like ARRAY["..."]
but I want to generate ARRAY["..."]::uuid[]
, what's the best option?
hacky and ugly, but it works:
[:&& [:cast included-uuids [:lift (symbol "uuid[]")]] :tzdb.tag_uuids]
open to improvements :)Iād probably go with :cast
/ :raw
for a situation like that. Open to suggestions on making that easier ā but weāre sort of at the mercy of Clojureās reader for that one.