This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-02-07
Channels
- # announcements (38)
- # asami (14)
- # beginners (35)
- # biff (3)
- # calva (29)
- # cider (20)
- # clj-kondo (7)
- # cljdoc (38)
- # clojure (64)
- # clojure-art (2)
- # clojure-australia (1)
- # clojure-dev (6)
- # clojure-europe (30)
- # clojure-nl (4)
- # clojure-spec (4)
- # clojure-uk (9)
- # clojured (3)
- # clojurescript (87)
- # cursive (17)
- # datahike (2)
- # datomic (10)
- # defnpodcast (2)
- # emacs (2)
- # events (1)
- # fulcro (25)
- # gratitude (1)
- # introduce-yourself (1)
- # jobs-discuss (21)
- # lsp (103)
- # malli (41)
- # meander (8)
- # minecraft (3)
- # missionary (3)
- # nextjournal (20)
- # off-topic (10)
- # pedestal (1)
- # polylith (15)
- # portal (6)
- # releases (2)
- # ring (1)
- # ring-swagger (2)
- # sci (4)
- # shadow-cljs (5)
- # spacemacs (3)
- # sql (11)
- # xtdb (3)
I have formatted the DSL with sql/format
. Now given the vector, is it convert it to the normal sql string as if I have formatted with the inline true
firsthand?
@i I don't understand your question - can you provide a small example?
(-> (select :tb)
(sql/format)
the above gives a vector based representation.
Given the above result, I want to have the inline form, as if I have used (sql/format :inline) initially.Why not just use (sql/format :inline true)
then?
(and this is a question for #honeysql not #sql really)
Also be aware that using :inline
formatting can open you up to SQL injection attacks so it's not something you generally want to do in production code.
> Why not just use `(sql/format :inline true)` then? The function is written without :inline. But sometimes for convenience I’d like to copy-paste the result in a inline form and instead of vector form to the sql console.
Then refactor the code. Split that function into one that just builds the data structure and call that from the current function with (sql/format)
as-is. Then you can call that new function and wrap it in (sql/format :inline true)
when you want the inline result for your SQL console.
Or add an optional argument that lets you invoke the original function with the :inline
flag passed in.
(although I'd be wary of encouraging other users of that code to produce inline-formatted SQL because of the injection potential)