Fix next.jdbc.date-time for java.sql.Date
An insert fails with > UnsupportedOperationException: null at java.sql/java.sql.Date.toInstant(Date.java:316) if you required `next.jdbc.date-time` and the value you are inserting is `java.sql.Date` because it is a subclass of `java.util.Date` and thus gets handled by https://github.com/seancorfield/next-jdbc/blob/master/src/next/jdbc/date_time.clj#L45 - but it doesn't support `toInstant` contrary to its superclass. The solution is to use `.setDate` with the value as-is instead of `.setTimestamp`.
This commit is contained in:
parent
ef0f33f919
commit
484ed90b7c
1 changed files with 5 additions and 1 deletions
|
|
@ -44,4 +44,8 @@
|
||||||
;; this is just to help PostgreSQL:
|
;; this is just to help PostgreSQL:
|
||||||
java.util.Date
|
java.util.Date
|
||||||
(set-parameter [^java.util.Date v ^PreparedStatement s ^long i]
|
(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 leave java.*sql*.Date as-is, it doesn't support toInstant
|
||||||
|
java.sql.Date
|
||||||
|
(set-parameter [^java.sql.Date v ^PreparedStatement s ^long i]
|
||||||
|
(.setDate s i v)))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue