Fix #43 by relaxing the spec for insert-multi!
Adds tests for `insert-multi!` that pass sequences instead of vectors.
This commit is contained in:
parent
821f9b1a5a
commit
4d7a5a440b
3 changed files with 23 additions and 3 deletions
|
|
@ -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!`.
|
||||
|
|
|
|||
|
|
@ -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 %)))))
|
||||
|
|
|
|||
|
|
@ -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]
|
||||
|
|
|
|||
Loading…
Reference in a new issue