Fix #24 by adding type hints

This commit is contained in:
Sean Corfield 2019-05-29 13:51:11 -07:00
parent fdfb0697ec
commit 382d1bef10
3 changed files with 26 additions and 17 deletions

View file

@ -23,4 +23,5 @@ Only accretive/fixative changes will be made from now on (Beta 1).
The following changes have been committed to the **master** branch and will be in the next release: The following changes have been committed to the **master** branch and will be in the next release:
* Fix #24 by adding return type hints to `next.jdbc` functions.
* Fix #22 by adding `next.jdbc.optional` with four map builders that omit `NULL` columns from the row hash maps. * Fix #22 by adding `next.jdbc.optional` with four map builders that omit `NULL` columns from the row hash maps.

View file

@ -87,6 +87,7 @@
* `redshift` -- `com.amazon.redshift.jdbc.Driver` -- no default port * `redshift` -- `com.amazon.redshift.jdbc.Driver` -- no default port
* `sqlite` -- `org.sqlite.JDBC` * `sqlite` -- `org.sqlite.JDBC`
* `sqlserver`, `mssql` -- `com.microsoft.sqlserver.jdbc.SQLServerDriver` -- `1433`" * `sqlserver`, `mssql` -- `com.microsoft.sqlserver.jdbc.SQLServerDriver` -- `1433`"
^javax.sql.DataSource
[spec] [spec]
(p/get-datasource spec)) (p/get-datasource spec))
@ -105,10 +106,12 @@
If you call `get-connection` on anything else, it will call `get-datasource` If you call `get-connection` on anything else, it will call `get-datasource`
first to try to get a `DataSource`, and then call `get-connection` on that." first to try to get a `DataSource`, and then call `get-connection` on that."
([spec] (^java.sql.Connection
(p/get-connection spec {})) [spec]
([spec opts] (p/get-connection spec {}))
(p/get-connection spec opts))) (^java.sql.Connection
[spec opts]
(p/get-connection spec opts)))
(defn prepare (defn prepare
"Given a connection to a database, and a vector containing SQL and any "Given a connection to a database, and a vector containing SQL and any
@ -123,10 +126,12 @@
See the list of options above (in the namespace docstring) for what can See the list of options above (in the namespace docstring) for what can
be passed to prepare." be passed to prepare."
([connection sql-params] (^java.sql.PreparedStatement
(p/prepare connection sql-params {})) [connection sql-params]
([connection sql-params opts] (p/prepare connection sql-params {}))
(p/prepare connection sql-params opts))) (^java.sql.PreparedStatement
[connection sql-params opts]
(p/prepare connection sql-params opts)))
(defn plan (defn plan
"General SQL execution function. "General SQL execution function.
@ -135,14 +140,17 @@
Can be called on a `PreparedStatement`, a `Connection`, or something that can Can be called on a `PreparedStatement`, a `Connection`, or something that can
produce a `Connection` via a `DataSource`." produce a `Connection` via a `DataSource`."
([stmt] (^clojure.lang.IReduceInit
(p/-execute stmt [] {})) [stmt]
([connectable sql-params] (p/-execute stmt [] {}))
(p/-execute connectable sql-params (^clojure.lang.IReduceInit
{:next.jdbc/sql-params sql-params})) [connectable sql-params]
([connectable sql-params opts] (p/-execute connectable sql-params
(p/-execute connectable sql-params {:next.jdbc/sql-params sql-params}))
(assoc opts :next.jdbc/sql-params sql-params)))) (^clojure.lang.IReduceInit
[connectable sql-params opts]
(p/-execute connectable sql-params
(assoc opts :next.jdbc/sql-params sql-params))))
(defn execute! (defn execute!
"General SQL execution function. "General SQL execution function.

View file

@ -27,7 +27,7 @@
Implementations are provided for `DataSource`, `PreparedStatement`, and Implementations are provided for `DataSource`, `PreparedStatement`, and
`Object`, on the assumption that an `Object` can be turned into a `DataSource`." `Object`, on the assumption that an `Object` can be turned into a `DataSource`."
(get-connection ^java.lang.AutoCloseable [this opts] (get-connection ^java.sql.Connection [this opts]
"Produce a new `java.sql.Connection` for use with `with-open`.")) "Produce a new `java.sql.Connection` for use with `with-open`."))
(defprotocol Executable (defprotocol Executable