Liking cljdoc? Tell your friends :D

next.jdbc.date-time

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).

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.

  • 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:

  • 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.

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).

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.

* 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:
* `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.
raw docstring

read-as-defaultclj

(read-as-default)

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. This is provided for completeness, to undo the effects of read-as-instant or read-as-local.

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. This is provided for
completeness, to undo the effects of `read-as-instant` or `read-as-local`.
sourceraw docstring

read-as-instantclj

(read-as-instant)

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.

Note that java.sql.Date columns will still be returns as-is because they cannot be converted to an instant (they lack a time component).

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`.

Note that `java.sql.Date` columns will still be returns as-is because they
cannot be converted to an instant (they lack a time component).
sourceraw docstring

read-as-localclj

(read-as-local)

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.

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.
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close