This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-02-02
Channels
- # announcements (3)
- # asami (29)
- # babashka (62)
- # beginners (131)
- # biff (7)
- # calva (31)
- # cider (5)
- # clerk (14)
- # clj-kondo (3)
- # cljsrn (12)
- # clojars (18)
- # clojure (72)
- # clojure-austin (17)
- # clojure-dev (6)
- # clojure-europe (31)
- # clojure-indonesia (1)
- # clojure-nl (1)
- # clojure-norway (18)
- # clojure-sweden (11)
- # clojure-uk (6)
- # clr (47)
- # conjure (42)
- # cursive (88)
- # datalevin (2)
- # datomic (25)
- # emacs (42)
- # exercism (1)
- # fulcro (10)
- # funcool (8)
- # gratitude (2)
- # honeysql (16)
- # introduce-yourself (5)
- # jobs-discuss (26)
- # leiningen (5)
- # lsp (31)
- # malli (21)
- # matcher-combinators (14)
- # missionary (2)
- # nbb (1)
- # off-topic (40)
- # pathom (38)
- # portal (2)
- # re-frame (7)
- # reagent (18)
- # reitit (1)
- # releases (5)
- # shadow-cljs (62)
- # sql (12)
- # testing (4)
- # xtdb (37)
Honey SQL 2 question:
Is this intentional behavior? If you have a [expression alias]
form inside a something like select
and the alias itself is an [:fn & args]
expression then it basically gets flattened out and compiled as if they were individual args. Simple example:
(sql/format {:select [[[:raw "A.B"] [:raw "C"]]]})
=> ["SELECT A.B AS \"raw\" ?" "C"]
You can make it work if you wrap the alias
expression in another vector, e.g. [expression [alias]]
(sql/format {:select [[[:raw "A.B"] [[:raw "C"]]]]})
=> ["SELECT A.B AS C"]
I'll open a GH issue if this is a bug but I wanted to double check firstNot a bug. Expected behavior.
Another Honey SQL question:
In Honey SQL 1, honeysql.core/format
worked with either arbitrary expressions or with query maps:
(honeysql.core/format (honeysql.core/call :+ 1 2))
=>
["(1 + 2)"]
However with Honey SQL 2 that doesn't work. There is honey.sql/format-expr
, but it doesn't accept any options like :dialect
or :quoted
that you can pass to honey.sql/format
. Anyone else running into this problem?
My use case is that I have a some functions returning Honey SQL and tests they compile the way I'd expectI hacked around it for now by manually binding things like sql/*dialect*
and calling sql/format-expr
, but it seems a little icky, since sql/*dialect*
is private. Luckily binding
doesn't care if things are private or not.
When I'm testing expressions, I usually wrap them in a where clause for format. But it's an interesting use case and I can see an argument for a format-expr with an expression and options. Can you create a GH issue?
Pushed a fix for it. If it seems to work for you via a git dep, I'll cut a new release.
Hey team, honeysql question:
Is there a way I can use the “jsonb” access functions, like ->>
:
I’m writing a query that looks something like:
WITH match AS (
SELECT * FROM items WHERE e = '9a70439e-33c0-4b34-91f5-efac20b58301'
) SELECT * FROM items JOIN match ON (match.v ->> 0)::uuid = items.e;
Having some trouble figuring out how to do (match.v ->> 0)::uuid
(playground for reference: https://www.db-fiddle.com/f/4jyoMCicNSZpjMt4jFYoz5/6944)Does https://cljdoc.org/d/com.github.seancorfield/honeysql/2.4.969/doc/getting-started/postgresql-support#operators-with---and- help? (and the pg-ops
ns it references)
Ah! Does the trick, thank you @U04V70XH6