parent
82f86ff9be
commit
a31426da6b
4 changed files with 20 additions and 2 deletions
|
|
@ -1,3 +1,8 @@
|
|||
## Coming in 0.9.6
|
||||
|
||||
* Filter `nil` conditions out of `where`/`merge-where`. Fix #246. (@seancorfield)
|
||||
* Fix reflection warning introduced in 0.9.5 (via PR #237).
|
||||
|
||||
## 0.9.5
|
||||
|
||||
* Support JDK11 (update Midje). PR #238. (@camsaul)
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@
|
|||
;; Use this function instead of `string/upper-case` as it will always use Locale/US.
|
||||
(def ^:private ^{:arglists '([s])} upper-case
|
||||
;; TODO - not sure if there's a JavaScript equivalent here we should be using as well
|
||||
#?(:clj (fn [s] (.. s toString (toUpperCase (java.util.Locale/US))))
|
||||
#?(:clj (fn [^String s] (.. s toString (toUpperCase (java.util.Locale/US))))
|
||||
:cljs string/upper-case))
|
||||
|
||||
(defn quote-identifier [x & {:keys [style split] :or {split true}}]
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@
|
|||
[:and preds])
|
||||
pred (if (>= 1 (count preds))
|
||||
(first preds)
|
||||
(into [logic-op] preds))]
|
||||
(into [logic-op] (remove nil? preds)))]
|
||||
[m pred logic-op]))
|
||||
|
||||
(defn where [& args]
|
||||
|
|
|
|||
|
|
@ -224,6 +224,11 @@
|
|||
(sql/format (apply merge-where sqlmap [])))))))
|
||||
|
||||
(deftest merge-where-test
|
||||
(is (= ["SELECT * FROM table WHERE (foo = bar AND quuz = xyzzy)"]
|
||||
(-> (select :*)
|
||||
(from :table)
|
||||
(where [:= :foo :bar] [:= :quuz :xyzzy])
|
||||
sql/format)))
|
||||
(is (= ["SELECT * FROM table WHERE (foo = bar AND quuz = xyzzy)"]
|
||||
(-> (select :*)
|
||||
(from :table)
|
||||
|
|
@ -231,4 +236,12 @@
|
|||
(merge-where [:= :quuz :xyzzy])
|
||||
sql/format))))
|
||||
|
||||
(deftest where-nil-params-test
|
||||
(testing "where called with nil parameters - see #246"
|
||||
(is (= ["SELECT * FROM table WHERE (foo = bar AND quuz = xyzzy)"]
|
||||
(-> (select :*)
|
||||
(from :table)
|
||||
(where nil [:= :foo :bar] nil [:= :quuz :xyzzy] nil)
|
||||
sql/format)))))
|
||||
|
||||
#?(:cljs (cljs.test/run-all-tests))
|
||||
|
|
|
|||
Loading…
Reference in a new issue