Fixes #42 by adding specs for next.jdbc.prepare API functions
This commit is contained in:
parent
79d6f5ef29
commit
3c32bfe13d
2 changed files with 21 additions and 1 deletions
|
|
@ -6,6 +6,7 @@ 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 #42 by adding specs for `execute-batch!` and `set-parameters` in `next.jdbc.prepare`.
|
||||
* Fix #40 by adding `next.jdbc.prepare/execute-batch!`.
|
||||
* Expose `next.jdbc.connect/dbtypes` as a table of known database types and aliases, along with their class name(s), port, and other JDBC string components.
|
||||
* Improved docstrings and documentation, especially around prepared statement handling.
|
||||
|
|
|
|||
|
|
@ -3,7 +3,9 @@
|
|||
(ns next.jdbc.specs
|
||||
"Specs for the core API of next.jdbc.
|
||||
|
||||
The functions from `next.jdbc` and `next.jdbc.sql` have specs here.
|
||||
The functions from `next.jdbc`, `next.jdbc.sql`, and `next.jdbc.prepare`
|
||||
have specs here.
|
||||
|
||||
Just `:args` are spec'd. These specs are intended to aid development
|
||||
with `next.jdbc` by catching simple errors in calling the library.
|
||||
The `connectable` argument is currently just `any?` but both
|
||||
|
|
@ -15,6 +17,7 @@
|
|||
(:require [clojure.spec.alpha :as s]
|
||||
[clojure.spec.test.alpha :as st]
|
||||
[next.jdbc :as jdbc]
|
||||
[next.jdbc.prepare :as prepare]
|
||||
[next.jdbc.sql :as sql])
|
||||
(:import (java.sql Connection PreparedStatement)
|
||||
(javax.sql DataSource)))
|
||||
|
|
@ -51,6 +54,11 @@
|
|||
(s/def ::sql-params (s/and vector?
|
||||
(s/cat :sql string?
|
||||
:params (s/* any?))))
|
||||
(s/def ::params (s/coll-of any? :kind sequential?))
|
||||
|
||||
(s/def ::batch-size pos-int?)
|
||||
(s/def ::large boolean?)
|
||||
(s/def ::batch-opts (s/keys :opt-un [::batch-size ::large]))
|
||||
|
||||
(s/fdef jdbc/get-datasource
|
||||
:args (s/cat :spec ::db-spec))
|
||||
|
|
@ -94,6 +102,15 @@
|
|||
:opts (s/? ::opts-map)))
|
||||
:body (s/* any?)))
|
||||
|
||||
(s/fdef prepare/execute-batch!
|
||||
:args (s/cat :ps ::prepared-statement
|
||||
:param-groups (s/coll-of ::params :kind sequential?)
|
||||
:opts (s/? ::batch-opts)))
|
||||
|
||||
(s/fdef prepare/set-parameters
|
||||
:args (s/cat :ps ::prepared-statement
|
||||
:params ::params))
|
||||
|
||||
(s/fdef sql/insert!
|
||||
:args (s/cat :connectable ::connectable
|
||||
:table keyword?
|
||||
|
|
@ -156,6 +173,8 @@
|
|||
`jdbc/execute-one!
|
||||
`jdbc/transact
|
||||
`jdbc/with-transaction
|
||||
`prepare/execute-batch!
|
||||
`prepare/set-parameters
|
||||
`sql/insert!
|
||||
`sql/insert-multi!
|
||||
`sql/query
|
||||
|
|
|
|||
Loading…
Reference in a new issue