address #430 by expanding escape hatch from #352

This commit is contained in:
Sean Corfield 2022-09-11 20:52:53 -07:00
parent a2571ef312
commit 02d20bd78c
2 changed files with 8 additions and 3 deletions

View file

@ -1,6 +1,7 @@
# Changes # Changes
* 2.3.next in progress * 2.3.next in progress
* Address [#430](https://github.com/seancorfield/honeysql/issues/430) by treating `:'` as introducing a name that should be treating literally and not formatted as a SQL entity (which respects quoting, dot-splitting, etc); this expands the "escape hatch" introduced in [#352](https://github.com/seancorfield/honeysql/issues/352) in 2.2.868.
* Address [#427](https://github.com/seancorfield/honeysql/issues/427) by adding `set-options!`. * Address [#427](https://github.com/seancorfield/honeysql/issues/427) by adding `set-options!`.
* 2.3.928 -- 2022-09-04 * 2.3.928 -- 2022-09-04
@ -37,7 +38,7 @@
* 2.2.868 -- 2022-02-21 * 2.2.868 -- 2022-02-21
* Address [#387](https://github.com/seancorfield/honeysql/issues/387) by making the function simpler. * Address [#387](https://github.com/seancorfield/honeysql/issues/387) by making the function simpler.
* Fix [#385](https://github.com/seancorfield/honeysql/issues/385) by quoting inlined UUIDs. * Fix [#385](https://github.com/seancorfield/honeysql/issues/385) by quoting inlined UUIDs.
* Address [#352](https://github.com/seancorfield/honeysql/issues/352) by treating `:'` as introducing a function name that should be formatted as a SQL entity (respects quoting, dot-splitting, etc). * Address [#352](https://github.com/seancorfield/honeysql/issues/352) by treating `:'` as introducing a function name that should not be formatted as a SQL entity (which respects quoting, dot-splitting, etc).
* 2.2.861 -- 2022-01-30 * 2.2.861 -- 2022-01-30
* Address [#382](https://github.com/seancorfield/honeysql/issues/382) by adding `:case-expr` for BigQuery support. * Address [#382](https://github.com/seancorfield/honeysql/issues/382) by adding `:case-expr` for BigQuery support.

View file

@ -314,6 +314,8 @@
{::wrapper {::wrapper
(fn [fk _] (param-value (fk)))})) (fn [fk _] (param-value (fk)))}))
(def ^:private ^:dynamic *formatted-column* (atom false))
(defn- format-var [x & [opts]] (defn- format-var [x & [opts]]
;; rather than name/namespace, we want to allow ;; rather than name/namespace, we want to allow
;; for multiple / in the %fun.call case so that ;; for multiple / in the %fun.call case so that
@ -329,6 +331,10 @@
(if *inline* (if *inline*
[(sqlize-value (param-value k))] [(sqlize-value (param-value k))]
["?" (->param k)])) ["?" (->param k)]))
(= \' (first c))
(do
(reset! *formatted-column* true)
[(subs c 1)])
:else :else
[(format-entity x opts)]))) [(format-entity x opts)])))
@ -939,8 +945,6 @@
(let [[if-exists tables & more] (destructure-drop-items params "DROP options")] (let [[if-exists tables & more] (destructure-drop-items params "DROP options")]
[(str/join " " (remove nil? (into [(sql-kw k) if-exists tables] more)))])) [(str/join " " (remove nil? (into [(sql-kw k) if-exists tables] more)))]))
(def ^:private ^:dynamic *formatted-column* (atom false))
(defn- format-single-column [xs] (defn- format-single-column [xs]
(reset! *formatted-column* true) (reset! *formatted-column* true)
(str/join " " (cons (format-simple-expr (first xs) "column operation") (str/join " " (cons (format-simple-expr (first xs) "column operation")