This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-05-25
Channels
- # announcements (9)
- # asami (69)
- # babashka (151)
- # babashka-sci-dev (34)
- # beginners (90)
- # cider (21)
- # clj-on-windows (17)
- # clj-otel (4)
- # cljsrn (5)
- # clojure (27)
- # clojure-austin (3)
- # clojure-europe (87)
- # clojure-gamedev (1)
- # clojure-nl (3)
- # clojure-norway (8)
- # clojure-poland (2)
- # clojure-uk (3)
- # clojured (10)
- # clojurescript (50)
- # core-async (73)
- # cursive (28)
- # data-science (2)
- # datomic (17)
- # etaoin (1)
- # honeysql (6)
- # introduce-yourself (3)
- # jobs (1)
- # joyride (12)
- # malli (5)
- # nbb (14)
- # off-topic (18)
- # pathom (4)
- # podcasts-discuss (2)
- # polylith (30)
- # project-updates (3)
- # re-frame (33)
- # reitit (1)
- # remote-jobs (13)
- # shadow-cljs (59)
- # sql (12)
- # tools-build (7)
- # xtdb (36)
target output:
SELECT "timestamp" from table
(sql/format {:select '["\"timestamp\""] :from 'table} {:inline true})
["SELECT '\"timestamp\"' FROM table"]
If you're using PostgreSQL (or some other relatively ANSI-compliant database), that's just normal quoting, so {:select :timestamp :from :table}
with {:quoted true}
Now I'm at my desk, instead of on my phone:
(! 506)-> clj
Clojure 1.9.0
user=> (require '[honey.sql :as sql])
nil
user=> (sql/format {:select :timestamp :from :table} {:quoted true})
["SELECT \"timestamp\" FROM \"table\""]
ANSI/PostgreSQL is the default dialect, but you can get quoting in other dialects too:
user=> (sql/format {:select :timestamp :from :table} {:dialect :mysql})
["SELECT `timestamp` FROM `table`"]
user=> (sql/format {:select :timestamp :from :table} {:dialect :sqlserver})
["SELECT [timestamp] FROM [table]"]
(if you specify a :dialect
, quoting is enabled by default and you can turn it off with :quoted false
; if you have a default dialect -- either ANSI/PostgreSQL out of the box or via set-dialect!
or register-dialect!
-- then you have to explicitly ask for :quoted true
)
👍 1