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:
* 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.

View file

@ -87,6 +87,7 @@
* `redshift` -- `com.amazon.redshift.jdbc.Driver` -- no default port
* `sqlite` -- `org.sqlite.JDBC`
* `sqlserver`, `mssql` -- `com.microsoft.sqlserver.jdbc.SQLServerDriver` -- `1433`"
^javax.sql.DataSource
[spec]
(p/get-datasource spec))
@ -105,9 +106,11 @@
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."
([spec]
(^java.sql.Connection
[spec]
(p/get-connection spec {}))
([spec opts]
(^java.sql.Connection
[spec opts]
(p/get-connection spec opts)))
(defn prepare
@ -123,9 +126,11 @@
See the list of options above (in the namespace docstring) for what can
be passed to prepare."
([connection sql-params]
(^java.sql.PreparedStatement
[connection sql-params]
(p/prepare connection sql-params {}))
([connection sql-params opts]
(^java.sql.PreparedStatement
[connection sql-params opts]
(p/prepare connection sql-params opts)))
(defn plan
@ -135,12 +140,15 @@
Can be called on a `PreparedStatement`, a `Connection`, or something that can
produce a `Connection` via a `DataSource`."
([stmt]
(^clojure.lang.IReduceInit
[stmt]
(p/-execute stmt [] {}))
([connectable sql-params]
(^clojure.lang.IReduceInit
[connectable sql-params]
(p/-execute connectable sql-params
{:next.jdbc/sql-params sql-params}))
([connectable sql-params opts]
(^clojure.lang.IReduceInit
[connectable sql-params opts]
(p/-execute connectable sql-params
(assoc opts :next.jdbc/sql-params sql-params))))

View file

@ -27,7 +27,7 @@
Implementations are provided for `DataSource`, `PreparedStatement`, and
`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`."))
(defprotocol Executable