diff --git a/CHANGELOG.md b/CHANGELOG.md index 6e3fcb0..53e2392 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/src/honey/sql.cljc b/src/honey/sql.cljc index f554f17..76a6717 100644 --- a/src/honey/sql.cljc +++ b/src/honey/sql.cljc @@ -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 diff --git a/test/honey/sql_test.cljc b/test/honey/sql_test.cljc index 952f359..1b54476 100644 --- a/test/honey/sql_test.cljc +++ b/test/honey/sql_test.cljc @@ -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))))