Skip to content

Commit

Permalink
fixes #533 by adding mostly undocumented *escape-?* dynvar
Browse files Browse the repository at this point in the history
Signed-off-by: Sean Corfield <sean@corfield.org>
  • Loading branch information
seancorfield committed Jun 13, 2024
1 parent 544992b commit b07ac78
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Changes

* 2.6.next in progress
* Address [#533](https://github.com/seancorfield/honeysql/issues/533) by adding `honey.sql/*escape-?*` which can be bound to `false` to prevent `?` being escaped to `??` when used as an operator, function, or
* Update JDK test matrix (adopt -> temurin, 19 -> 21).

* 2.6.1147 -- 2024-06-12
Expand Down
6 changes: 5 additions & 1 deletion src/honey/sql.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@
;; caching data to detect expressions that cannot be cached:
(def ^:private ^:dynamic *caching* nil)
(def ^:private ^:dynamic *numbered* nil)
;; #533 mostly undocumented dynvar to prevent ? -> ?? escaping:
(def ^:no-doc ^:dynamic *escape-?* true)

;; clause helpers

Expand Down Expand Up @@ -339,7 +341,9 @@
Any ? is escaped to ??."
[k]
(when k
(let [n (str/replace (name k) "?" "??")]
(let [n (cond-> (name k)
*escape-?*
(str/replace "?" "??"))]
(if (= \' (first n))
(let [ident (subs n 1)
ident-l (str/lower-case ident)]
Expand Down

0 comments on commit b07ac78

Please sign in to comment.