diff --git a/CHANGELOG.md b/CHANGELOG.md index a9d5374..a5903e2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changes +* 2.2.next in progress + * Fix #380 by correcting test for function type in `register-clause!`. + * 2.2.858 -- 2022-01-20 * Address #377 by adding `honey.sql/map=` to convert a hash map into an equality condition (for a `WHERE` clause). * Address #351 by adding a `:cache` option to `honey.sql/format` (for Clojure only, not ClojureScript). diff --git a/src/honey/sql.cljc b/src/honey/sql.cljc index 8939f8f..a36e56b 100644 --- a/src/honey/sql.cljc +++ b/src/honey/sql.cljc @@ -1466,7 +1466,7 @@ f (if (keyword? k) (get @clause-format k) formatter)] - (when-not (and f (fn? f)) + (when-not (and f (or (fn? f) (and (var? f) (fn? (deref f)))) ) (throw (ex-info "The formatter must be a function or existing clause" {:type (type formatter)}))) (swap! base-clause-order add-clause-before clause before) @@ -1487,7 +1487,7 @@ f (if (keyword? k) (get @special-syntax k) formatter)] - (when-not (and f (fn? f)) + (when-not (and f (or (fn? f) (and (var? f) (fn? (deref f))))) (throw (ex-info "The formatter must be a function or existing fn name" {:type (type formatter)}))) (swap! special-syntax assoc function f)))) diff --git a/test/honey/sql_test.cljc b/test/honey/sql_test.cljc index 652e8b1..0844ff1 100644 --- a/test/honey/sql_test.cljc +++ b/test/honey/sql_test.cljc @@ -722,7 +722,6 @@ ORDER BY id = ? DESC (is (:disallowed (ex-data e)))))))) ;; should not produce: ["SELECT foo, bar FROM mytable ORDER BY foo; select * from users"] - (deftest issue-319-test (testing "that registering a clause is idempotent" (is (= ["FOO"] @@ -731,6 +730,10 @@ ORDER BY id = ? DESC (sut/register-clause! :foo (constantly ["FOO"]) nil) (format {:foo []})))))) +(deftest issue-380-test + (testing "that registering a clause by name works" + (is (map? (sut/register-clause! :qualify :having :window))))) + (deftest issue-321-linting (testing "empty IN is ignored by default" (is (= ["WHERE x IN ()"]