]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- CheckConstraint will copy its 'initially', 'deferrable',
authorMike Bayer <mike_mp@zzzcomputing.com>
Sat, 8 Jan 2011 20:24:20 +0000 (15:24 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sat, 8 Jan 2011 20:24:20 +0000 (15:24 -0500)
and '_create_rule' attributes within a copy()/tometadata()
[ticket:2000]

CHANGES
lib/sqlalchemy/schema.py
test/engine/test_metadata.py

diff --git a/CHANGES b/CHANGES
index 46ce7c1932fb0f7b0ac30f53914c532adb7fec67..86a1e98bade52ae9d6501e31ddae6f26c0d01b54 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -99,6 +99,10 @@ CHANGES
     to int, for DBAPIs such as pymssql that naively call 
     str() on values.
 
+  - CheckConstraint will copy its 'initially', 'deferrable',
+    and '_create_rule' attributes within a copy()/tometadata()
+    [ticket:2000]
+
 - engine
   - The "unicode warning" against non-unicode bind data
     is now raised only when the
index d83a4fa4247d5ca32710fa9a5a51d3e93f7e0f9d..af0c7620077590310929a4ff6d71d82d890d5da9 100644 (file)
@@ -1657,7 +1657,11 @@ class CheckConstraint(Constraint):
     __visit_name__ = property(__visit_name__)
 
     def copy(self, **kw):
-        return CheckConstraint(self.sqltext, name=self.name)
+        return CheckConstraint(self.sqltext, 
+                                name=self.name,
+                                initially=self.initially,
+                                deferrable=self.deferrable,
+                                _create_rule=self._create_rule)
 
 class ForeignKeyConstraint(Constraint):
     """A table-level FOREIGN KEY constraint.
index b6a718a6c0e93b0bf05c7fe88c7d07971034a5fc..e32af57d9563f7b84651a7e623f83e097645b842 100644 (file)
@@ -123,6 +123,20 @@ class MetaDataTest(TestBase, ComparesTables):
             eq_(getattr(fk1c, k), kw[k])
             eq_(getattr(fk2c, k), kw[k])
 
+    def test_check_constraint_copy(self):
+        r = lambda x: x
+        c = CheckConstraint("foo bar", 
+                            name='name', 
+                            initially=True, 
+                            deferrable=True, 
+                            _create_rule = r)
+        c2 = c.copy()
+        eq_(c2.name, 'name')
+        eq_(str(c2.sqltext), "foo bar")
+        eq_(c2.initially, True)
+        eq_(c2.deferrable, True)
+        assert c2._create_rule is r
+
     def test_fk_construct(self):
         c1 = Column('foo', Integer)
         c2 = Column('bar', Integer)