next.jdbc.date-time
(source)Optional namespace that extends `next.jdbc.prepare/SettableParameter`
to various date/time types so that they will all be treated as SQL
timestamps (which also supports date and time column types) and has
functions to extend `next.jdbc.result-set/ReadableColumn`.
Simply requiring this namespace will extend the `SettableParameter` protocol
to the four types listed below.
In addition, there are several `read-as-*` functions here that will
extend `next.jdbc.result-set/ReadableColumn` to allow `java.sql.Date`
and `java.sql.Timestamp` columns to be read as (converted to) various
Java Time types automatically. The expectation is that you will call at
most one of these, at application startup, to enable the behavior you want.
Database support for Java Time:
* H2 and SQLite support conversion of Java Time (`Instant`, `LocalDate`,
`LocalDateTime`) out of the box,
* Nearly all databases support conversion of `java.util.Date` out of
the box -- except PostgreSQL apparently!
Types supported by this namespace:
* `java.time.Instant`
* `java.time.LocalDate`
* `java.time.LocalDateTime`
* `java.util.Date` -- mainly for PostgreSQL
PostgreSQL does not seem able to convert `java.util.Date` to a SQL
timestamp by default (every other database can!) so you'll probably
need to require this namespace, even if you don't use Java Time, when
working with PostgreSQL.
For more info about this library see:
https://cljdoc.org/d/com.github.seancorfield/next.jdbc/1.3.909/doc/readmePublic Variable | Short Description |
---|---|
read-as-default (clj) | After calling this function, `next.jdbc.result-set/ReadableColumn` will be extended to `java.sql.Date` and `java.sql.Timestamp` so that any date or timestamp columns will be read as-is. |
read-as-instant (clj) | After calling this function, `next.jdbc.result-set/ReadableColumn` will be extended to (`java.sql.Date` and) `java.sql.Timestamp` so that any timestamp columns will automatically be read as `java.time.Instant`. |
read-as-local (clj) | After calling this function, `next.jdbc.result-set/ReadableColumn` will be extended to `java.sql.Date` and `java.sql.Timestamp` so that any date or timestamp columns will automatically be read as `java.time.LocalDate` or `java.time.LocalDateTime` respectively. |