fix #385 by quoting inlined uuids

This commit is contained in:
Sean Corfield 2022-02-09 10:20:36 -08:00
parent c7c634d694
commit 4bf76920ef
3 changed files with 23 additions and 13 deletions

View file

@ -1,6 +1,7 @@
# Changes # Changes
* 2.2.next in progress * 2.2.next in progress
* 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 be formatted as a SQL entity (respects quoting, dot-splitting, etc).
* 2.2.861 -- 2022-01-30 * 2.2.861 -- 2022-01-30

View file

@ -253,6 +253,9 @@
(string? x) (str \' (str/replace x "'" "''") \') (string? x) (str \' (str/replace x "'" "''") \')
(ident? x) (sql-kw x) (ident? x) (sql-kw x)
(vector? x) (str "[" (str/join ", " (map #'sqlize-value x)) "]") (vector? x) (str "[" (str/join ", " (map #'sqlize-value x)) "]")
;; issue 385: quoted UUIDs for PostgreSQL/ANSI
#?(:clj (instance? java.util.UUID x) :cljs false)
(str \' x \') ; UUID cannot contain quotes
:else (str x))) :else (str x)))
(defn- param-value [k] (defn- param-value [k]

View file

@ -362,6 +362,12 @@
#_{:parameterizer :mysql-fill}) #_{:parameterizer :mysql-fill})
["WHERE (foo = ?) AND (bar = ?) AND (quux = ?)" "foo" "bar" "quux"])))) ["WHERE (foo = ?) AND (bar = ?) AND (quux = ?)" "foo" "bar" "quux"]))))
#?(:clj
(deftest issue-385-test
(let [u (java.util.UUID/randomUUID)]
(is (= [(str "VALUES ('" (str u) "')")]
(format {:values [[u]]} {:inline true}))))))
(deftest set-before-from (deftest set-before-from
;; issue 235 ;; issue 235
(is (= (is (=