-
Notifications
You must be signed in to change notification settings - Fork 21.9k
Closed
Description
This is a follow up to #13793.
We currently map all PostgreSQL ranges directly to Ruby ranges. Because the Ruby range is inferior to the PostgreSQL range we can not make an exact conversion. This leads to the following issues:
- Ruby ranges to not support exclusive lower bounds. We have some magic that tries to deal with that but it's not accurate and not complete: See here, here and here
- Ruby ranges do not support unbound beginnings or ends. We are trying to simulate this using
X::Infinity
values. However those infinity values do not exist for every possible range type. See Support for Postgresql date/time ranges #12694 for an example.
The solution is to introduce a new type called PGRange
. The PostgresqlAdapter
will no longer map to Ruby ranges but to this new type. We can model that type to easily support unbound ranges and exclusive beginnings and endings. The PGRange
type should act mostly like a Ruby range. For cases where you are dependent on an actual Ruby range and for backwards compatibility we add a method to convert a PGRange
to a Ruby range: to_range
.
axelson