honeysql

sheluchin 2024-04-24T18:14:00.997569Z

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-himik 2024-04-24T19:21:09.198589Z

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

p-himik 2024-04-24T19:21:38.057339Z

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

sheluchin 2024-04-24T20:49:42.367749Z

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