summaryrefslogtreecommitdiff
path: root/test/dialect/postgresql
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2022-12-21 16:10:34 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2022-12-21 16:12:53 -0500
commitb973cbd8939f2cc0e29c668fffd507958c3e455a (patch)
treec42e547b00e50ed06fe1601b09fbb3053ab53b6e /test/dialect/postgresql
parent9749a394b19e78086103b3c01144a03061bb9c75 (diff)
downloadsqlalchemy-b973cbd8939f2cc0e29c668fffd507958c3e455a.tar.gz
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
Diffstat (limited to 'test/dialect/postgresql')
-rw-r--r--test/dialect/postgresql/test_types.py19
1 files changed, 19 insertions, 0 deletions
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