From b973cbd8939f2cc0e29c668fffd507958c3e455a Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Wed, 21 Dec 2022 16:10:34 -0500 Subject: check for adapt to same class in AbstractRange Fixed regression where newly revised PostgreSQL range types such as :class:`_postgresql.INT4RANGE` could not be set up as the impl of a :class:`.TypeDecorator` custom type, instead raising a ``TypeError``. Fixes: #9020 Change-Id: Ib881c3c7f63d000f49a09185a8663659a9970aa9 --- test/dialect/postgresql/test_types.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'test/dialect/postgresql') diff --git a/test/dialect/postgresql/test_types.py b/test/dialect/postgresql/test_types.py index caa758b0d..e9d5e561f 100644 --- a/test/dialect/postgresql/test_types.py +++ b/test/dialect/postgresql/test_types.py @@ -4486,6 +4486,25 @@ class _RangeTypeRoundTrip(_RangeComparisonFixtures, fixtures.TablesTest): cols = insp.get_columns("data_table") assert isinstance(cols[0]["type"], self._col_type) + def test_type_decorator_round_trip(self, connection, metadata): + """test #9020""" + + class MyRange(TypeDecorator): + cache_ok = True + impl = self._col_type + + table = Table( + "typedec_table", + metadata, + Column("range", MyRange, primary_key=True), + ) + table.create(connection) + connection.execute(table.insert(), {"range": self._data_obj()}) + data = connection.execute( + select(table.c.range).where(table.c.range == self._data_obj()) + ).fetchall() + eq_(data, [(self._data_obj(),)]) + def test_textual_round_trip_w_dialect_type(self, connection): """test #8690""" data_table = self.tables.data_table -- cgit v1.2.1