Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Range type support #7070

beikov started this conversation in Design Proposals
Jul 25, 2023 · 0 comments
Discussion options

Some DBMS support ranges natively i.e. have a custom SQL types for ranges: https://www.postgresql.org/docs/current/rangetypes.html

It would be cool if we could add support for this. If the DBMS doesn't support that, we could treat it like a composite type with properties min, max, minInclusive and maxInclusive that map to multiple columns through the custom composite type facility, similar to how we did it for OffsetDateTime/ZonedDateTime.

The idea is to introduce two interfaces:

final class Range<T>{
 // Null indicates negative infinite
 @Nullable T getMin();
 // Null indicates positive infinite
 @Nullable T getMax();
 boolean isMinInclusive();
 boolean isMaxInclusive();
 static Range<T> of(T min, T max, boolean minInclusive, boolean maxInclusive);
 static Range<T> all();
 static Range<T> min(T min, boolean inclusive);
 static Range<T> max(T max, boolean inclusive);
}

In addition to adding the type, I suggest adding a overlaps predicate that checks if two ranges overlap and a contains predicate that checks if a value is within a range.

You must be logged in to vote

Replies: 0 comments

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

AltStyle によって変換されたページ (->オリジナル) /