Add PostgreSQL like Range/Multirange Functions
Is your feature request related to a problem? Please describe.
pgx defines a Range[T] type that can be used to store PostgreSQL ranges. I use the ranges in a CopyFrom call, but sometimes the call contains one or more overlapping ranges that are not allowed in my table definition. Therefore, the whole CopyFrom fails. It would be helpful if I could use the functions/operators as defined in https://www.postgresql.org/docs/current/functions-range.html to check the records I have before insert. I could imagine that for other use cases other functions/operators are helpful if they can be applied already in Go.
Describe the solution you'd like
I would like to add these functions in a file range_functions.go and range_functions_test.go in the pgtype package. Would you include these in pgx (pull request) or is it better to make a separate project for these functions?
Describe alternatives you've considered
A separate project that uses pgtype.Range[T].
I think this would make sense as a separate project at least to start. It might even make sense to have these types be independent of pgtype.Range[T]. Range types and functionality would be useful in Go independent of PostgreSQL. They could be modeled off of the PostgreSQL system. And an adapter could be made that implements RangeValuer and RangeScanner. This would let the projects integrate without direct dependencies. For example, it would be like the shopspring/decimal package is used with pgx.
Thanks,
I was already working on it, see https://github.com/munnik/pgx_range_operator. Not yet a stable interface, so comments are more than welcome.