Address #124 by fixing bug in builder; adding tests
This commit is contained in:
parent
26b8fa1600
commit
4de1d445ec
2 changed files with 14 additions and 1 deletions
|
|
@ -155,7 +155,7 @@
|
||||||
where-params (cond (map? where-params)
|
where-params (cond (map? where-params)
|
||||||
(by-keys where-params :where opts)
|
(by-keys where-params :where opts)
|
||||||
(= :all where-params)
|
(= :all where-params)
|
||||||
[]
|
[nil]
|
||||||
:else
|
:else
|
||||||
(into [(str "WHERE " (first where-params))]
|
(into [(str "WHERE " (first where-params))]
|
||||||
(rest where-params)))
|
(rest where-params)))
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,19 @@
|
||||||
(is (= 1 ((column :FRUIT/ID) (first rs))))
|
(is (= 1 ((column :FRUIT/ID) (first rs))))
|
||||||
(is (= 4 ((column :FRUIT/ID) (last rs))))))
|
(is (= 4 ((column :FRUIT/ID) (last rs))))))
|
||||||
|
|
||||||
|
(deftest test-find-all-offset
|
||||||
|
(let [ds-opts (jdbc/with-options (ds) (default-options))
|
||||||
|
rs (sql/find-by-keys ds-opts :fruit :all
|
||||||
|
(assoc (if (or (mysql?) (sqlite?))
|
||||||
|
{:limit 2 :offset 1}
|
||||||
|
{:offset 1 :fetch 2})
|
||||||
|
:order-by [:id]))]
|
||||||
|
(is (= 2 (count rs)))
|
||||||
|
(is (every? map? rs))
|
||||||
|
(is (every? meta rs))
|
||||||
|
(is (= 2 ((column :FRUIT/ID) (first rs))))
|
||||||
|
(is (= 3 ((column :FRUIT/ID) (last rs))))))
|
||||||
|
|
||||||
(deftest test-find-by-keys
|
(deftest test-find-by-keys
|
||||||
(let [ds-opts (jdbc/with-options (ds) (default-options))]
|
(let [ds-opts (jdbc/with-options (ds) (default-options))]
|
||||||
(let [rs (sql/find-by-keys ds-opts :fruit {:appearance "neon-green"})]
|
(let [rs (sql/find-by-keys ds-opts :fruit {:appearance "neon-green"})]
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue