From 98c2a679707432e6707ba70f1aebd10b28b861a3 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Sat, 29 Nov 2014 14:44:26 -0500 Subject: - Fixed bug in :meth:`.Table.tometadata` method where the :class:`.CheckConstraint` associated with a :class:`.Boolean` or :class:`.Enum` type object would be doubled in the target table. The copy process now tracks the production of this constraint object as local to a type object. fixes #3260 --- test/sql/test_metadata.py | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'test/sql') diff --git a/test/sql/test_metadata.py b/test/sql/test_metadata.py index 3f24fd07d..74044e3bb 100644 --- a/test/sql/test_metadata.py +++ b/test/sql/test_metadata.py @@ -1473,6 +1473,46 @@ class SchemaTypeTest(fixtures.TestBase): m1.create_all(testing.db) + def test_boolean_constraint_type_doesnt_double(self): + m1 = MetaData() + + t1 = Table('x', m1, Column("flag", Boolean())) + eq_( + len([ + c for c in t1.constraints + if isinstance(c, CheckConstraint)]), + 1 + ) + m2 = MetaData() + t2 = t1.tometadata(m2) + + eq_( + len([ + c for c in t2.constraints + if isinstance(c, CheckConstraint)]), + 1 + ) + + def test_enum_constraint_type_doesnt_double(self): + m1 = MetaData() + + t1 = Table('x', m1, Column("flag", Enum('a', 'b', 'c'))) + eq_( + len([ + c for c in t1.constraints + if isinstance(c, CheckConstraint)]), + 1 + ) + m2 = MetaData() + t2 = t1.tometadata(m2) + + eq_( + len([ + c for c in t2.constraints + if isinstance(c, CheckConstraint)]), + 1 + ) + class SchemaTest(fixtures.TestBase, AssertsCompiledSQL): -- cgit v1.2.1