diff --git a/CHANGELOG.md b/CHANGELOG.md index f7c82a9..4038bf2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changes +* 2.4.next in progress + * Fix [#509](https://github.com/seancorfield/honeysql/issues/509) by checking for `ident?` before checking keyword/symbol. + * 2.4.1078 -- 2023-10-07 * Address [#507](https://github.com/seancorfield/honeysql/issues/507) by clarifying formatting of `:cast` in **Special Syntax**. * Fix [#505](https://github.com/seancorfield/honeysql/issues/505) by rewriting the helper merge function to handle both keywords and symbols properly. diff --git a/src/honey/sql.cljc b/src/honey/sql.cljc index ff3e90d..b3a1645 100644 --- a/src/honey/sql.cljc +++ b/src/honey/sql.cljc @@ -936,7 +936,7 @@ (defn- format-values [k xs] (let [first-xs (when (sequential? xs) (first (drop-while ident? xs)))] - (cond (contains? #{:default 'default} xs) + (cond (and (ident? xs) (contains? #{:default 'default} xs)) [(str (sql-kw xs) " " (sql-kw k))] (empty? xs) [(str (sql-kw k) " ()")] diff --git a/test/honey/sql_test.cljc b/test/honey/sql_test.cljc index 987b7fb..911253a 100644 --- a/test/honey/sql_test.cljc +++ b/test/honey/sql_test.cljc @@ -1269,6 +1269,13 @@ ORDER BY id = ? DESC (is (= ["SELECT FOO(bar) AT TIME ZONE 'UTC'"] (sut/format {:select [[[:at-time-zone [:foo :bar] :UTC]]]})))) +(deftest unhashable-value-509 + (let [unhashable (reify Object + (toString [_] "unhashable") + (hashCode [_] (throw (ex-info "Unsupported" {}))))] + (is (= ["INSERT INTO table VALUES (?)" unhashable] + (sut/format {:insert-into :table :values [[unhashable]]}))))) + (comment ;; partial workaround for #407: (sut/format {:select :f.* :from [[:foo [:f :for :system-time]]] :where [:= :f.id 1]})