From ed535649d423020c816e66869016992df25e456e Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Thu, 27 Aug 2015 18:04:25 -0400 Subject: - The :class:`.TypeDecorator` type extender will now work in conjunction with a :class:`.SchemaType` implementation, typically :class:`.Enum` or :class:`.Boolean` with regards to ensuring that the per-table events are propagated from the implementation type to the outer type. These events are used to ensure that the constraints or Postgresql types (e.g. ENUM) are correctly created (and possibly dropped) along with the parent table. fixes #2919 --- test/dialect/postgresql/test_types.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'test/dialect/postgresql') diff --git a/test/dialect/postgresql/test_types.py b/test/dialect/postgresql/test_types.py index 8eab9d4b9..7aad23255 100644 --- a/test/dialect/postgresql/test_types.py +++ b/test/dialect/postgresql/test_types.py @@ -499,6 +499,34 @@ class EnumTest(fixtures.TestBase, AssertsExecutionResults): finally: metadata.drop_all() + @testing.provide_metadata + def test_custom_subclass(self): + class MyEnum(TypeDecorator): + impl = Enum('oneHI', 'twoHI', 'threeHI', name='myenum') + + def process_bind_param(self, value, dialect): + if value is not None: + value += "HI" + return value + + def process_result_value(self, value, dialect): + if value is not None: + value += "THERE" + return value + + t1 = Table( + 'table1', self.metadata, + Column('data', MyEnum()) + ) + self.metadata.create_all(testing.db) + + with testing.db.connect() as conn: + conn.execute(t1.insert(), {"data": "two"}) + eq_( + conn.scalar(select([t1.c.data])), + "twoHITHERE" + ) + class OIDTest(fixtures.TestBase): __only_on__ = 'postgresql' -- cgit v1.2.1