pgjdbc / r2dbc-postgresql

Postgresql R2DBC Driver

Home Page:https://r2dbc.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error when storing BC dates (e.g. "0000-12-31T01:01:00Z")

mwinkels-bol opened this issue · comments

Bug Report

When storing a date that is BC (Before Christ) an error is thrown.

Versions

  • Driver: 0.9.3.RELEASE
  • Database: 12.11 / 13.3
  • Java: 17
  • OS: MacOS / Ubuntu

Current Behavior

A date that is BC (e.g. Year 0) will throw an error e.g. [22008] date/time field value out of range: "0000-12-31T01:01:00Z"
The driver is using Instant::toString for conversion, but this ignores the ERA (BC) and the database does not accept this as a value.
PostgreSQL can properly store these dates, but the driver implementation now prevents users from inserting it.

Steps to reproduce

As part of AbstractCodecIntegrationTests

testCodec(Instant.class, Instant.parse("0000-12-31T01:01:00Z"), "TIMESTAMPTZ");

Expected behavior/code

Dates BC should also be inserted by the driver.

Looking into our temporal support, the way we handle overflow values and extremes aren't ideal. all of this requires a bit of revision to align with the awesome work done in the JDBC Postgres driver.