Addresses #76 by not converting SQL Date/Timestamp types

This commit is contained in:
Sean Corfield 2019-11-18 09:35:32 -08:00
parent c7e2e61bb6
commit 32e9f338d5
2 changed files with 10 additions and 2 deletions

View file

@ -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.10 release:
* Fix #76 by avoiding conversions on `java.sql.Date` and `java.sql.Timestamp`.
* Add testing against Microsoft SQL Server (run tests with environment variables `NEXT_JDBC_TEST_MSSQL=yes` and `MSSQL_SA_PASSWORD` set to your local -- `127.0.0.1:1433` -- SQL Server `sa` user password; assumes that it can create and drop `fruit` and `fruit_time` tables in the `model` database).
* Add testing against MySQL (run tests with environment variables `NEXT_JDBC_TEST_MYSQL=yes` and `MYSQL_ROOT_PASSWORD` set to your local -- `127.0.0.1:3306` -- MySQL `root` user password; assumes you have already created an empty database called `clojure_test`).
* Bump several JDBC driver versions for up-to-date testing.

View file

@ -30,7 +30,7 @@
(set! *warn-on-reflection* true)
(extend-protocol p/SettableParameter
;; Java Time type conversion
;; Java Time type conversion:
java.time.Instant
(set-parameter [^java.time.Instant v ^PreparedStatement s ^long i]
(.setTimestamp s i (Timestamp/from v)))
@ -44,4 +44,11 @@
;; this is just to help PostgreSQL:
java.util.Date
(set-parameter [^java.util.Date v ^PreparedStatement s ^long i]
(.setTimestamp s i (Timestamp/from (.toInstant v)))))
(.setTimestamp s i (Timestamp/from (.toInstant v))))
;; but avoid unnecessary conversions for SQL Date and Timestamp:
java.sql.Date
(set-parameter [^java.sql.Date v ^PreparedStatement s ^long i]
(.setDate s i v))
java.sql.Timestamp
(set-parameter [^java.sql.Timestamp v ^PreparedStatement s ^long i]
(.setTimestamp s i v)))