Document PR #64

Add to change log, Getting Started, and ns docstring for 
`next.jdbc.specs`. Also note docs in GitHub are for **master** now.
This commit is contained in:
Sean Corfield 2019-09-14 13:32:34 -07:00
parent ea2af9db11
commit e03de7828a
4 changed files with 32 additions and 39 deletions

View file

@ -6,7 +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.7 release:
* None.
* Add `next.jdbc.specs/unstrument`. PR #64 (@gerred).
## Stable Builds

View file

@ -8,7 +8,7 @@ The latest versions on Clojars and on cljdoc:
[![Clojars Project](https://clojars.org/seancorfield/next.jdbc/latest-version.svg)](https://clojars.org/seancorfield/next.jdbc) [![cljdoc badge](https://cljdoc.org/badge/seancorfield/next.jdbc)](https://cljdoc.org/d/seancorfield/next.jdbc/CURRENT)
This documentation is for the 1.0.7 release -- [see the CHANGELOG](CHANGELOG.md).
This documentation is for **master** after the 1.0.7 release -- [see the CHANGELOG](CHANGELOG.md).
* [Getting Started](/doc/getting-started.md)
* [Migrating from `clojure.java.jdbc`](/doc/migration-from-clojure-java-jdbc.md)

View file

@ -250,4 +250,10 @@ Call to #'next.jdbc/execute! did not conform to spec.
In the `:problems` output, you'll see the `:path [:sql :sql-params]` and `:pred vector?` for the `:val "SELECT * FROM fruit"`. Without the specs' assistance, this mistake would produce a more cryptic error, a `ClassCastException`, that a `Character` cannot be cast to a `String`, from inside `next.jdbc.prepare`.
A convenience function also exists to revert that instrumentation:
```clojure
(specs/unstrument) ; undoes the instrumentation of all next.jdbc API functions
```
[Friendly SQL Functions :>](/doc/friendly-sql-functions.md)

View file

@ -13,7 +13,8 @@
extend `Sourceable` or `Connectable`, those specs will likely be too strict.
In addition, there is an `instrument` function that provides a simple
way to instrument all of the `next.jdbc` functions."
way to instrument all of the `next.jdbc` functions, and `unstrument`
to undo that."
(:require [clojure.spec.alpha :as s]
[clojure.spec.test.alpha :as st]
[next.jdbc :as jdbc]
@ -183,8 +184,8 @@
:where ::sql-params)
:opts (s/? ::opts-map)))
(defn instrument []
(st/instrument [`jdbc/get-datasource
(def ^:private fns-with-specs
[`jdbc/get-datasource
`jdbc/get-connection
`jdbc/prepare
`jdbc/plan
@ -201,24 +202,10 @@
`sql/find-by-keys
`sql/get-by-id
`sql/update!
`sql/delete!]))
`sql/delete!])
(defn instrument []
(st/instrument fns-with-specs))
(defn unstrument []
(st/unstrument [`jdbc/get-datasource
`jdbc/get-connection
`jdbc/prepare
`jdbc/plan
`jdbc/execute!
`jdbc/execute-one!
`jdbc/transact
`jdbc/with-transaction
`connection/->pool
`prepare/execute-batch!
`prepare/set-parameters
`sql/insert!
`sql/insert-multi!
`sql/query
`sql/find-by-keys
`sql/get-by-id
`sql/update!
`sql/delete!]))
(st/unstrument fns-with-specs))