diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2017-09-23 12:19:56 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2017-09-25 19:30:51 -0400 |
| commit | 35a1f5481a28837490037a6bd99d63590f748933 (patch) | |
| tree | cd42d87738d90c015fdb09a93f2f379234982360 /test/sql/test_metadata.py | |
| parent | 08430e689f1a0190f671636016b12ff2ca08531f (diff) | |
| download | sqlalchemy-35a1f5481a28837490037a6bd99d63590f748933.tar.gz | |
Make a common approach for "emulated" types
Internal refinements to the :class:`.Enum`, :class:`.Interval`, and
:class:`.Boolean` types, which now extend a common mixin
:class:`.Emulated` that indicates a type that provides Python-side
emulation of a DB native type, switching out to the DB native type when a
supporting backend is in use. The Postgresql :class:`.INTERVAL` type
when used directly will now include the correct type coercion rules for
SQL expressions that also take effect for :class:`.sqltypes.Interval`
(such as adding a date to an interval yields a datetime).
Change-Id: Ifb9f9d7cbd9f5990dcb2abb583193e9e92b789ad
Fixes: #4088
Diffstat (limited to 'test/sql/test_metadata.py')
| -rw-r--r-- | test/sql/test_metadata.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/test/sql/test_metadata.py b/test/sql/test_metadata.py index e204375f4..35e0c9c1d 100644 --- a/test/sql/test_metadata.py +++ b/test/sql/test_metadata.py @@ -1797,6 +1797,24 @@ class SchemaTypeTest(fixtures.TestBase): is_true(y_copy.type._create_events) + # for Postgresql, this will emit CREATE TYPE + m.dispatch.before_create(t1, testing.db) + try: + eq_(t1.c.y.type.evt_targets, (t1, )) + finally: + # do the drop so that Postgresql emits DROP TYPE + m.dispatch.after_drop(t1, testing.db) + + def test_enum_nonnative_column_copy_transfers_events(self): + m = MetaData() + + type_ = self.WrapEnum('a', 'b', 'c', name='foo', native_enum=False) + y = Column('y', type_) + y_copy = y.copy() + t1 = Table('x', m, y_copy) + + is_true(y_copy.type._create_events) + m.dispatch.before_create(t1, testing.db) eq_(t1.c.y.type.evt_targets, (t1, )) |
