fix #434 by special-casing array

This commit is contained in:
Sean Corfield 2022-11-17 22:39:48 -08:00
parent 15cf3ae588
commit 562b20634a
3 changed files with 9 additions and 1 deletions

View file

@ -1,6 +1,7 @@
# Changes
* 2.4.next in progress
* Fix [#434](https://github.com/seancorfield/honeysql/issues/434) by special-casing `:'ARRAY`.
* Fix [#441](https://github.com/seancorfield/honeysql/issues/441) by adding `:replace-into` to in-flight clause order (as well as registering it for the `:mysql` dialect).
* 2.4.947 -- 2022-11-05

View file

@ -275,7 +275,10 @@
[k]
(let [n (str/replace (name k) "?" "??")]
(if (= \' (first n))
(format-entity (keyword (subs n 1 (count n))))
(let [ident (subs n 1 (count n))
ident-l (str/lower-case ident)]
(binding [*quoted* (when-not (contains? #{"array"} ident-l) *quoted*)]
(format-entity (keyword ident))))
(-> n (dehyphen) (upper-case)))))
(defn- sym->kw

View file

@ -1015,3 +1015,7 @@ ORDER BY id = ? DESC
;; don't quote if quoting disabled (illegal SQL):
(is (= ["SELECT A, B C"] (sut/format {:select [:A (keyword "B C")]}
{:quoted false}))))
(deftest issue-434-case-quoting
(is (= ["SELECT ARRAY (SELECT \"oid\" FROM \"pg_proc\" WHERE \"proname\" LIKE 'bytea%')"]
(sut/format {:select [[[:'ARRAY {:select :oid :from :pg_proc :where [:like :proname [:inline "bytea%"]]}]]]} :quoted true))))