Skip to content

Analysis should catch mismatch for types with or without timezone in PostgreSQL instances #1481

Open
@nigredo-tori

Description

@nigredo-tori
  • Writing or reading OffsetDateTime or Instant as TIMESTAMP is generally an error.
  • Writing or reading LocalDateTime as TIMESTAMPTZ 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions