Description
- Writing or reading
OffsetDateTime
orInstant
asTIMESTAMP
is generally an error. - Writing or reading
LocalDateTime
asTIMESTAMPTZ
is generally an error.
This was highlighted for me by a recent-ish change, where the implementation for corresponding instances for PostgreSQL has changed. For example, where previously Instant
was passed to the database as java.util.Date
, with the system timezone, it is now passed as OffsetDateTime
with zero offset. This means that any code that was writing Instant
to TIMESTAMP
columns was silently broken by this. Reading this data has its own set of problems.
The most annoying part for me is that the analysis checks in place don't catch that, because (AFAICT) pgjdbc doesn't correctly label output columns types as TIMESTAMP_WITH_TIMEZONE
to preserve compatibility with Hibernate. 🤦 Maybe there is some other piece of metadata we can use here? If, say, getColumnTypeName
produces different values for TIMESTAMP
and TIMESTAMPTZ
, we can use that to disambiguate the two. Although I imagine that would require an overhaul of the Get
and Meta
machinery.