fix #380 by accounting for vars
This commit is contained in:
parent
30209b6cc7
commit
139de6f56c
3 changed files with 9 additions and 3 deletions
|
|
@ -1,5 +1,8 @@
|
||||||
# Changes
|
# Changes
|
||||||
|
|
||||||
|
* 2.2.next in progress
|
||||||
|
* Fix #380 by correcting test for function type in `register-clause!`.
|
||||||
|
|
||||||
* 2.2.858 -- 2022-01-20
|
* 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 #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).
|
* Address #351 by adding a `:cache` option to `honey.sql/format` (for Clojure only, not ClojureScript).
|
||||||
|
|
|
||||||
|
|
@ -1466,7 +1466,7 @@
|
||||||
f (if (keyword? k)
|
f (if (keyword? k)
|
||||||
(get @clause-format k)
|
(get @clause-format k)
|
||||||
formatter)]
|
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"
|
(throw (ex-info "The formatter must be a function or existing clause"
|
||||||
{:type (type formatter)})))
|
{:type (type formatter)})))
|
||||||
(swap! base-clause-order add-clause-before clause before)
|
(swap! base-clause-order add-clause-before clause before)
|
||||||
|
|
@ -1487,7 +1487,7 @@
|
||||||
f (if (keyword? k)
|
f (if (keyword? k)
|
||||||
(get @special-syntax k)
|
(get @special-syntax k)
|
||||||
formatter)]
|
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"
|
(throw (ex-info "The formatter must be a function or existing fn name"
|
||||||
{:type (type formatter)})))
|
{:type (type formatter)})))
|
||||||
(swap! special-syntax assoc function f))))
|
(swap! special-syntax assoc function f))))
|
||||||
|
|
|
||||||
|
|
@ -722,7 +722,6 @@ ORDER BY id = ? DESC
|
||||||
(is (:disallowed (ex-data e))))))))
|
(is (:disallowed (ex-data e))))))))
|
||||||
;; should not produce: ["SELECT foo, bar FROM mytable ORDER BY foo; select * from users"]
|
;; should not produce: ["SELECT foo, bar FROM mytable ORDER BY foo; select * from users"]
|
||||||
|
|
||||||
|
|
||||||
(deftest issue-319-test
|
(deftest issue-319-test
|
||||||
(testing "that registering a clause is idempotent"
|
(testing "that registering a clause is idempotent"
|
||||||
(is (= ["FOO"]
|
(is (= ["FOO"]
|
||||||
|
|
@ -731,6 +730,10 @@ ORDER BY id = ? DESC
|
||||||
(sut/register-clause! :foo (constantly ["FOO"]) nil)
|
(sut/register-clause! :foo (constantly ["FOO"]) nil)
|
||||||
(format {:foo []}))))))
|
(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
|
(deftest issue-321-linting
|
||||||
(testing "empty IN is ignored by default"
|
(testing "empty IN is ignored by default"
|
||||||
(is (= ["WHERE x IN ()"]
|
(is (= ["WHERE x IN ()"]
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue