Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Instant and OffsetDateTime #656

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

lbruun
Copy link

@lbruun lbruun commented Sep 21, 2023

Support for Range<Instant> and Range<OffsetDateTime>

Support for additional Java range types is added as per the text in bold in table below.

Supported PostgreSQL types:

PostgreSQL column type Java type
int4range Range<Integer>
int8range Range<Long>
numrange Range<BigDecimal>
tsrange Range<LocalDateTime>
tstzrange Range<ZonedDateTime>, Range<OffsetDateTime> or Range<Instant>
daterange Range<LocalDate>

The change is fully backwards compatible.

Fixes Issue #288 and Issue #96.

Support for Instant-based comparison

Comparison functionality which can check for "functionally equivalent" has been added. With the existing "strict comparison" the following two ranges:

     x1 : ['2007-12-03T09:30.00Z',)
     x2 : ['2007-12-03T10:30.00+01:00',)

is seen as two completely different ranges and contains() produces unexpected results in that the 2007-12-03T09:30.00Z Instant is not contained in the x2 range. (see Issue #655)

This PR adds new methods which performs Instant-based comparison where applicable, meaning for types OffsetDateTime and ZonedDateTime. Fixes Issue #655.

I don't see why not any application would want to always do contains(x, true) going forward, but I didn't dare break backward compatibility. Hence the new feature is purely opt-in based. There is probably a slight performance degradation by performing Instant-based comparison instead of strict comparison, but I doubt it is truly measurable.

The variable ZONE_DATE_TIME (now OFFSET_DATE_TIME) is really a pattern
for offset-based timestamps, not zoned timestamps. The variable should be named
accordingly.
@lbruun lbruun changed the title Support for instant and OffsetDateTime Support for Instant and OffsetDateTime Sep 21, 2023
@vladmihalcea
Copy link
Owner

Thanks, I'll review it when I have some time.

@vladmihalcea
Copy link
Owner

@lbruun This PR is just for the 6.2 branch, therefore I cannot integrate it unless the changes are provided for all modules.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants