pg.ddx.io  psycopg/psycopg GitHub issues and pull requests  
help / color / mirror / Atom feed
From: jerch (@jerch) <noreply+jerch@github.com>
To: psycopg/psycopg <noreply+psycopg-psycopg@github.com>
Subject: [psycopg/psycopg] issue #1157: proposal: retrieve range value dumper from inner_oid setting
Date: Thu, 04 Sep 2025 19:01:54 +0000
Message-ID: <gh-psycopg-psycopg-1157@github.com> (raw)

This is a continuation of #1143. I was able to get this work in the python version (example for int4range):

```python
class Int4RangeBinaryDumper(RangeBinaryDumper):
    oid = _oids.INT4RANGE_OID
    inner_oid = _oids.INT4_OID    # would have to be defined on all range classes using fixed dumping

    def dump(self, obj: Range[Any]) -> Buffer | None:
        if (item := self._get_item(obj)) is not None:
            #dump = self._tx.get_dumper(item, self._adapt_format).dump
            dump = self._tx.get_dumper_by_oid(self.inner_oid, Format.BINARY).dump
        else:
            dump = fail_dump

        return dump_range_binary(obj, dump)

```
(`dump` can be handled on the super class, it is here just to show the difference...)

If you like the idea, I can create another MR for it.

A few things would have to be discussed for this:
- Should it be only applied for range dumpers from `set_types` or for all?
- Also for text format?
- Apply it to all range dumper classes, or just those that have the current ambiguity (int4range vs. int8range)?

view thread (16+ messages)  latest in thread

Message-ID: <gh-psycopg-psycopg-1157@github.com>
Permalink:  ../gh-psycopg-psycopg-1157@github.com/

 · 


This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox