Merge pull request #25 from seancorfield/issue-24
Fix #24 by adding type hints at the top level
This commit is contained in:
commit
13ed4eb6a6
17 changed files with 54 additions and 17 deletions
|
|
@ -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.
|
||||||
|
|
|
||||||
|
|
@ -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,9 +106,11 @@
|
||||||
|
|
||||||
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
|
||||||
|
[spec]
|
||||||
(p/get-connection spec {}))
|
(p/get-connection spec {}))
|
||||||
([spec opts]
|
(^java.sql.Connection
|
||||||
|
[spec opts]
|
||||||
(p/get-connection spec opts)))
|
(p/get-connection spec opts)))
|
||||||
|
|
||||||
(defn prepare
|
(defn prepare
|
||||||
|
|
@ -123,9 +126,11 @@
|
||||||
|
|
||||||
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
|
||||||
|
[connection sql-params]
|
||||||
(p/prepare 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)))
|
(p/prepare connection sql-params opts)))
|
||||||
|
|
||||||
(defn plan
|
(defn plan
|
||||||
|
|
@ -135,12 +140,15 @@
|
||||||
|
|
||||||
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
|
||||||
|
[stmt]
|
||||||
(p/-execute stmt [] {}))
|
(p/-execute stmt [] {}))
|
||||||
([connectable sql-params]
|
(^clojure.lang.IReduceInit
|
||||||
|
[connectable sql-params]
|
||||||
(p/-execute connectable sql-params
|
(p/-execute connectable sql-params
|
||||||
{:next.jdbc/sql-params sql-params}))
|
{:next.jdbc/sql-params sql-params}))
|
||||||
([connectable sql-params opts]
|
(^clojure.lang.IReduceInit
|
||||||
|
[connectable sql-params opts]
|
||||||
(p/-execute connectable sql-params
|
(p/-execute connectable sql-params
|
||||||
(assoc opts :next.jdbc/sql-params sql-params))))
|
(assoc opts :next.jdbc/sql-params sql-params))))
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,8 @@
|
||||||
from Clojure data."
|
from Clojure data."
|
||||||
(:require [clojure.string :as str]))
|
(:require [clojure.string :as str]))
|
||||||
|
|
||||||
|
(set! *warn-on-reflection* true)
|
||||||
|
|
||||||
(defn ansi "ANSI \"quoting\"" [s] (str \" s \"))
|
(defn ansi "ANSI \"quoting\"" [s] (str \" s \"))
|
||||||
|
|
||||||
(defn mysql "MySQL `quoting`" [s] (str \` s \`))
|
(defn mysql "MySQL `quoting`" [s] (str \` s \`))
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,8 @@
|
||||||
(:import (java.sql Connection PreparedStatement)
|
(:import (java.sql Connection PreparedStatement)
|
||||||
(javax.sql DataSource)))
|
(javax.sql DataSource)))
|
||||||
|
|
||||||
|
(set! *warn-on-reflection* true)
|
||||||
|
|
||||||
(s/def ::dbtype string?)
|
(s/def ::dbtype string?)
|
||||||
(s/def ::dbname string?)
|
(s/def ::dbname string?)
|
||||||
(s/def ::classname string?)
|
(s/def ::classname string?)
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,8 @@
|
||||||
(:require [clojure.string :as str]
|
(:require [clojure.string :as str]
|
||||||
[next.jdbc :refer [execute! execute-one!]]))
|
[next.jdbc :refer [execute! execute-one!]]))
|
||||||
|
|
||||||
|
(set! *warn-on-reflection* true)
|
||||||
|
|
||||||
(defn- by-keys
|
(defn- by-keys
|
||||||
"Given a hash map of column names and values and a clause type
|
"Given a hash map of column names and values and a clause type
|
||||||
(`:set`, `:where`), return a vector of a SQL clause and its parameters.
|
(`:set`, `:where`), return a vector of a SQL clause and its parameters.
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,8 @@
|
||||||
[next.jdbc.connection :as c]
|
[next.jdbc.connection :as c]
|
||||||
[next.jdbc.protocols :as p]))
|
[next.jdbc.protocols :as p]))
|
||||||
|
|
||||||
|
(set! *warn-on-reflection* true)
|
||||||
|
|
||||||
(def ^:private db-name "clojure_test")
|
(def ^:private db-name "clojure_test")
|
||||||
|
|
||||||
(deftest test-aliases-and-defaults
|
(deftest test-aliases-and-defaults
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,8 @@
|
||||||
[next.jdbc.protocols :as p]
|
[next.jdbc.protocols :as p]
|
||||||
[next.jdbc.test-fixtures :refer [with-test-db ds]]))
|
[next.jdbc.test-fixtures :refer [with-test-db ds]]))
|
||||||
|
|
||||||
|
(set! *warn-on-reflection* true)
|
||||||
|
|
||||||
(use-fixtures :once with-test-db)
|
(use-fixtures :once with-test-db)
|
||||||
|
|
||||||
(deftest test-map-row-builder
|
(deftest test-map-row-builder
|
||||||
|
|
|
||||||
|
|
@ -9,3 +9,5 @@
|
||||||
actually work they way they're supposed to!"
|
actually work they way they're supposed to!"
|
||||||
(:require [clojure.test :refer [deftest is testing]]
|
(:require [clojure.test :refer [deftest is testing]]
|
||||||
[next.jdbc.prepare :refer :all]))
|
[next.jdbc.prepare :refer :all]))
|
||||||
|
|
||||||
|
(set! *warn-on-reflection* true)
|
||||||
|
|
|
||||||
|
|
@ -5,3 +5,5 @@
|
||||||
at this level tho'..."
|
at this level tho'..."
|
||||||
(:require [clojure.test :refer [deftest is testing]]
|
(:require [clojure.test :refer [deftest is testing]]
|
||||||
[next.jdbc.protocols :refer :all]))
|
[next.jdbc.protocols :refer :all]))
|
||||||
|
|
||||||
|
(set! *warn-on-reflection* true)
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,8 @@
|
||||||
[next.jdbc.quoted :refer [ansi mysql sql-server oracle postgres
|
[next.jdbc.quoted :refer [ansi mysql sql-server oracle postgres
|
||||||
schema]]))
|
schema]]))
|
||||||
|
|
||||||
|
(set! *warn-on-reflection* true)
|
||||||
|
|
||||||
(deftest basic-quoting
|
(deftest basic-quoting
|
||||||
(are [quote-fn quoted] (= (quote-fn "x") quoted)
|
(are [quote-fn quoted] (= (quote-fn "x") quoted)
|
||||||
ansi "\"x\""
|
ansi "\"x\""
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,8 @@
|
||||||
[next.jdbc.test-fixtures :refer [with-test-db ds]])
|
[next.jdbc.test-fixtures :refer [with-test-db ds]])
|
||||||
(:import (java.sql ResultSet ResultSetMetaData)))
|
(:import (java.sql ResultSet ResultSetMetaData)))
|
||||||
|
|
||||||
|
(set! *warn-on-reflection* true)
|
||||||
|
|
||||||
(use-fixtures :once with-test-db)
|
(use-fixtures :once with-test-db)
|
||||||
|
|
||||||
(deftest test-datafy-nav
|
(deftest test-datafy-nav
|
||||||
|
|
|
||||||
|
|
@ -7,3 +7,5 @@
|
||||||
next.jdbc and next.jdbc.sql namespaces."
|
next.jdbc and next.jdbc.sql namespaces."
|
||||||
(:require [clojure.test :refer [deftest is testing]]
|
(:require [clojure.test :refer [deftest is testing]]
|
||||||
[next.jdbc.specs :refer :all]))
|
[next.jdbc.specs :refer :all]))
|
||||||
|
|
||||||
|
(set! *warn-on-reflection* true)
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,8 @@
|
||||||
[next.jdbc.test-fixtures
|
[next.jdbc.test-fixtures
|
||||||
:refer [with-test-db ds derby? sqlite?]]))
|
:refer [with-test-db ds derby? sqlite?]]))
|
||||||
|
|
||||||
|
(set! *warn-on-reflection* true)
|
||||||
|
|
||||||
(use-fixtures :once with-test-db)
|
(use-fixtures :once with-test-db)
|
||||||
|
|
||||||
(specs/instrument)
|
(specs/instrument)
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,8 @@
|
||||||
(:require [next.jdbc :as jdbc]
|
(:require [next.jdbc :as jdbc]
|
||||||
[next.jdbc.sql :as sql]))
|
[next.jdbc.sql :as sql]))
|
||||||
|
|
||||||
|
(set! *warn-on-reflection* true)
|
||||||
|
|
||||||
(def ^:private test-derby {:dbtype "derby" :dbname "clojure_test_derby" :create true})
|
(def ^:private test-derby {:dbtype "derby" :dbname "clojure_test_derby" :create true})
|
||||||
|
|
||||||
(def ^:private test-h2-mem {:dbtype "h2:mem" :dbname "clojure_test_h2_mem"})
|
(def ^:private test-h2-mem {:dbtype "h2:mem" :dbname "clojure_test_h2_mem"})
|
||||||
|
|
|
||||||
|
|
@ -4,3 +4,5 @@
|
||||||
"Stub test namespace for transaction handling."
|
"Stub test namespace for transaction handling."
|
||||||
(:require [clojure.test :refer [deftest is testing]]
|
(:require [clojure.test :refer [deftest is testing]]
|
||||||
[next.jdbc.transaction :refer :all]))
|
[next.jdbc.transaction :refer :all]))
|
||||||
|
|
||||||
|
(set! *warn-on-reflection* true)
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,8 @@
|
||||||
[next.jdbc.specs :as specs])
|
[next.jdbc.specs :as specs])
|
||||||
(:import (java.sql ResultSet ResultSetMetaData)))
|
(:import (java.sql ResultSet ResultSetMetaData)))
|
||||||
|
|
||||||
|
(set! *warn-on-reflection* true)
|
||||||
|
|
||||||
(use-fixtures :once with-test-db)
|
(use-fixtures :once with-test-db)
|
||||||
|
|
||||||
(specs/instrument)
|
(specs/instrument)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue