This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-08-07
Channels
- # aleph (7)
- # announcements (1)
- # babashka (31)
- # beginners (18)
- # calva (23)
- # cljdoc (10)
- # clojure (74)
- # clojure-europe (42)
- # clojure-norway (10)
- # clojure-uk (1)
- # clojurescript (19)
- # core-async (2)
- # cursive (188)
- # data-science (11)
- # datahike (1)
- # datascript (4)
- # events (2)
- # figwheel-main (23)
- # fulcro (5)
- # gratitude (2)
- # honeysql (3)
- # hyperfiddle (120)
- # jobs (3)
- # lsp (3)
- # meander (6)
- # missionary (8)
- # nrepl (1)
- # off-topic (5)
- # rdf (11)
- # releases (4)
- # remote-jobs (1)
- # sci (5)
- # tools-build (3)
- # tools-deps (14)
I believe there’s a bug around IN
clauses and inline
formatting when using parameters, but I just wanted to check I’m not missing a step (or that this is explicitly not supported) before I open an issue:
;NO PARAMETERS:
(hsql/format
{:select :* :from :some-table :where [:in :id [1 2 3]]}
{})
=> ["SELECT * FROM some_table WHERE id IN (?, ?, ?)" 1 2 3]
(hsql/format
{:select :* :from :some-table :where [:in :id [1 2 3]]}
{:inline true})
=> ["SELECT * FROM some_table WHERE id IN (1, 2, 3)"] ;correct
;PARAMETERS:
(hsql/format
{:select :* :from :some-table :where [:in :id :?ids]}
{:params {:ids [1 2 3]}})
=> ["SELECT * FROM some_table WHERE id IN (?, ?, ?)" 1 2 3] ;correct without inline
(hsql/format
{:select :* :from :some-table :where [:in :id :?ids]}
{:params {:ids (seq [1 2 3])}
:inline true})
=> ["SELECT * FROM some_table WHERE id IN (1 2 3)"] ;no commas
(hsql/format
{:select :* :from :some-table :where [:in :id :?ids]}
{:params {:ids [1 2 3]}
:inline true})
=> ["SELECT * FROM some_table WHERE id IN [1, 2, 3]"] ;square brackets
(hsql/format
{:select :* :from :some-table :where [:in :id :?ids]}
{:params {:ids #{1 2 3}}
:inline true})
=> ["SELECT * FROM some_table WHERE id IN #{1 3 2}"] ;set, no commas
(hsql/format
{:select :* :from :some-table :where [:in :id :?ids]}
{:params {:ids (map inc [1 2 3])}
:inline true})
=> ["SELECT * FROM some_table WHERE id IN clojure.lang.LazySeq@7c42"] ;etc
Seems like it's intended and documented: https://cljdoc.org/d/com.github.seancorfield/honeysql/2.4.1045/doc/all-the-options?q=%3Ainline#inline
> everything else is just turned into a string (by calling str
)
🙌 2