diff --git a/CHANGELOG.md b/CHANGELOG.md index 53b9a69..58353b3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,8 +6,9 @@ Only accretive/fixative changes will be made from now on. The following changes have been committed to the **master** branch since the 1.0.1 release: -* Fix #45 by adding TimesTen driver support. +* Fix #45 by adding [TimesTen](https://www.oracle.com/database/technologies/related/timesten.html) driver support. * Fix #44 so that `insert-multi!` with an empty `rows` vector returns `[]`. +* Fix #43 by adjusting the spec for `insert-multi!` to "require less" of the `cols` and `rows` arguments. * Fix #42 by adding specs for `execute-batch!` and `set-parameters` in `next.jdbc.prepare`. * Fix #41 by improving docstrings and documentation, especially around prepared statement handling. * Fix #40 by adding `next.jdbc.prepare/execute-batch!`. diff --git a/src/next/jdbc/specs.clj b/src/next/jdbc/specs.clj index eb73599..a073b69 100644 --- a/src/next/jdbc/specs.clj +++ b/src/next/jdbc/specs.clj @@ -126,8 +126,8 @@ (s/fdef sql/insert-multi! :args (s/and (s/cat :connectable ::connectable :table keyword? - :cols (s/coll-of keyword? :kind vector?) - :rows (s/coll-of (s/coll-of any? :kind vector?) :kind vector?) + :cols (s/coll-of keyword? :kind sequential?) + :rows (s/coll-of (s/coll-of any? :kind sequential?) :kind sequential?) :opts (s/? ::opts-map)) #(apply = (count (:cols %)) (map count (:rows %))))) diff --git a/test/next/jdbc/sql_test.clj b/test/next/jdbc/sql_test.clj index 6f25152..c15638b 100644 --- a/test/next/jdbc/sql_test.clj +++ b/test/next/jdbc/sql_test.clj @@ -155,6 +155,25 @@ (is (= {:next.jdbc/update-count 2} (sql/delete! (ds) :fruit ["id > ?" 4]))) (is (= 4 (count (sql/query (ds) ["select * from fruit"]))))) + (testing "multiple insert/delete with sequential cols/rows" ; per #43 + (is (= (cond (derby?) + [{:1 nil}] ; WTF Apache Derby? + (sqlite?) + [{(keyword "last_insert_rowid()") 11}] + :else + [{:FRUIT/ID 9} {:FRUIT/ID 10} {:FRUIT/ID 11}]) + (sql/insert-multi! (ds) :fruit + '(:name :appearance :cost :grade) + '(("Kiwi" "green & fuzzy" 100 99.9) + ("Grape" "black" 10 50) + ("Lemon" "yellow" 20 9.9))))) + (is (= 7 (count (sql/query (ds) ["select * from fruit"])))) + (is (= {:next.jdbc/update-count 1} + (sql/delete! (ds) :fruit {:id 9}))) + (is (= 6 (count (sql/query (ds) ["select * from fruit"])))) + (is (= {:next.jdbc/update-count 2} + (sql/delete! (ds) :fruit ["id > ?" 4]))) + (is (= 4 (count (sql/query (ds) ["select * from fruit"]))))) (testing "empty insert-multi!" ; per #44 (is (= [] (sql/insert-multi! (ds) :fruit [:name :appearance :cost :grade]