summaryrefslogtreecommitdiff
path: root/test/sql
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2014-11-29 14:44:26 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2014-11-29 14:46:34 -0500
commit98c2a679707432e6707ba70f1aebd10b28b861a3 (patch)
tree3059b56231a8dfc3df208df2b57230855d295867 /test/sql
parentde62497b03274c860ea2554dfbacb3064ce02c19 (diff)
downloadsqlalchemy-98c2a679707432e6707ba70f1aebd10b28b861a3.tar.gz
- 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
Diffstat (limited to 'test/sql')
-rw-r--r--test/sql/test_metadata.py40
1 files changed, 40 insertions, 0 deletions
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):