You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
PyGreSQL has no support for range types (PostgreSQL 9.2) and multirange types (PostgreSQL 14). Values are returned as strings like '[1,5)', 'empty' or '{[1,5),[7,9)}', and there is no Python type to pass them as parameters.
psycopg 3 has Range and Multirange classes with casts and adapters for the built-in types (int4range, int8range, numrange, daterange, tsrange, tstzrange and their multiranges) and for user-defined range types.
Proper support would need:
a Range class (bounds, inclusivity, empty, unbounded) and a Multirange class, in pg and pgdb,
casts that convert the bounds with the cast of the subtype (from pg_range), also for user-defined range types and as elements of arrays and records,
adaptation of these objects as parameters, also inline and in arrays.
Returning Range objects instead of strings by default would break existing code, so this is planned for 7.0. Until then, a typecast function can be registered with set_typecast().
I moved this to 6.4, since most of it can be added without breaking existing code: the Range and Multirange classes, their adaptation as parameters (also inline and as elements of arrays and records), and casts for the built-in and user-defined range types that can be enabled explicitly, like the ipaddress support in 6.3. Range values will still be returned as strings by default. Making the new casts the default would be a breaking change, so that stays in 7.0, see #152.
Activity
Cito commentedon Nov 23, 2026
I moved this to 6.4, since most of it can be added without breaking existing code: the
RangeandMultirangeclasses, their adaptation as parameters (also inline and as elements of arrays and records), and casts for the built-in and user-defined range types that can be enabled explicitly, like theipaddresssupport in 6.3. Range values will still be returned as strings by default. Making the new casts the default would be a breaking change, so that stays in 7.0, see #152.