Fork me on GitHub
#honeysql
<
2024-04-24
>
sheluchin18:04:00

If you have a reserved SQL keyword as a column name, is there some way to query for it without using the fully-qualified keyword?

(-> (hh/select :to)
      (hh/from :foo))
  ;; "SELECT to FROM foo"
  (-> (hh/select :foo/to)
      (hh/from :foo))
  ;; "SELECT  FROM foo"
desired query is SELECT "to" FROM foo.

p-himik19:04:09

Yes, the :quoted parameter is responsible for that. There are other parameters that can affect the relevant behavior.

p-himik19:04:38

(sql/format {:select :to})
=> ["SELECT to"]
(sql/format {:select :to} {:quoted true})
=> ["SELECT \"to\""]

sheluchin20:04:42

@U2FRKM4TW do you know if there is a way to apply it to a single column in the selection?