Merge pull request #78 from dball/fix-parameterizable-for-nil
Fix the parameterizable protocol to include nil
This commit is contained in:
commit
bf7c6c67b2
3 changed files with 18 additions and 0 deletions
|
|
@ -1,5 +1,7 @@
|
|||
## 0.6.1 In development
|
||||
|
||||
* Define parameterizable protocol on nil (@dball)
|
||||
|
||||
## 0.6.0
|
||||
|
||||
* Convert seq param values to literal sql param lists (@dball)
|
||||
|
|
|
|||
|
|
@ -258,6 +258,11 @@
|
|||
clojure.lang.IPersistentSet
|
||||
(to-params [value pname]
|
||||
(to-params (seq value) pname))
|
||||
nil
|
||||
(to-params [value pname]
|
||||
(swap! *params* conj value)
|
||||
(swap! *param-names* conj pname)
|
||||
(*parameterizer*))
|
||||
java.lang.Object
|
||||
(to-params [value pname]
|
||||
(swap! *params* conj value)
|
||||
|
|
|
|||
|
|
@ -82,6 +82,17 @@
|
|||
sql/format))))
|
||||
|
||||
(deftest test-operators
|
||||
(testing "="
|
||||
(testing "with nil"
|
||||
(is (= ["SELECT * FROM customers WHERE name IS NULL"]
|
||||
(sql/format {:select [:*]
|
||||
:from [:customers]
|
||||
:where [:= :name nil]})))
|
||||
(is (= ["SELECT * FROM customers WHERE name = ?" nil]
|
||||
(sql/format {:select [:*]
|
||||
:from [:customers]
|
||||
:where [:= :name :?name]}
|
||||
{:name nil})))))
|
||||
(testing "in"
|
||||
(doseq [[cname coll] [[:vector []] [:set #{}] [:list '()]]]
|
||||
(testing (str "with values from a " (name cname))
|
||||
|
|
|
|||
Loading…
Reference in a new issue