humdum, wonder how I can output "
around a table name, e.g.
select * from "user";
That's :quoting :ansi
in the format
call.
user=> (require '[honeysql.core :as h])
nil
user=> (h/format {:select [:*] :from [:user]})
["SELECT * FROM user"]
user=> (h/format {:select [:*] :from [:user]} :quoting :ansi)
["SELECT * FROM \"user\""]
user=>
nice, thank you! 🙂
Note: this changes in v2 since ANSI dialect is the default and format
requires an options hash map instead of named arguments:
user=> (require '[honey.sql :as h])
nil
user=> (h/format {:select [:*] :from [:user]})
["SELECT * FROM user"]
user=> (h/format {:select [:*] :from [:user]} {:quoted true})
["SELECT * FROM \"user\""]
user=>
opts maps sounds like a nice thing
actually, the codebase that I'm working with now uses a schema qualified name, e.g. backend.user
, but I was wondering on how to avoid this (would allow moving to another schema etc.), so specifying :quoting
in the format calls hasn't been in use in this codebase
user=> (h/format {:select [:*] :from [:backend.user]} :quoting :ansi)
["SELECT * FROM \"backend\".\"user\""]
user=>