Open pascalbetz opened 3 years ago
Thanks for putting this together. I'm not available for a couple of days, but I'll take a look at this next week and give feedback then :)
Begin/Endless Ranges
Postgres supports "infinite" values for lower/upper boundary. This corresponds to begin/endless Ranges in Crystal.
E.g.: [, 50)
=> nil..50
This makes the Range that gets created Range(T | Nil, T | Nil)
Is this OK?
Another possibility would be to use the Datatypes MIN/MAX value (e.g. Int64::MIN) and make sure the boundary is inclusive:
E.g.: [, 50)
=> Int32::MIN..50
so we would not create begin/endless Ranges. (This would not map what is in Postgres though, so I don't like it)
Empty Ranges
Postgres empty ranges are currently implemented as exclusive Ranges with the same value for lower and upper boundary.
E.g. 0...0
The values I picked to build these empty ranges are arbitrary though and this does not map exactly what is stored in Postgres.
There is no way to differentiate between
(,)::int4range
and [0,0]::int4range
because both values end up in Range.new(0, 0)
.
What do you think?
@will I plan on fixing the build and adding multiranges (Postgres 14) support if this can get merged. Let me know what you think.
Implements Ranges (https://github.com/will/crystal-pg/issues/164)
This is as far as i can get with my limited Crystal knowhow...so i'll need some help to finish it.