checkconstraint copy not complete

Issue #2000 resolved
Mike Bayer repo owner created an issue

patch:

diff -r 09961886961668dcf452a1139eb8584bf48e2539 lib/sqlalchemy/schema.py
--- a/lib/sqlalchemy/schema.py  Mon Dec 13 10:23:59 2010 -0500
+++ b/lib/sqlalchemy/schema.py  Tue Dec 14 10:40:43 2010 -0500
@@ -1638,7 +1638,10 @@
     __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.

test for one part of this, however more tests in test_metadata should be present for all the attributes:

from sqlalchemy import *
from sqlalchemy import schema
from sqlalchemy.dialects import postgresql
from test.lib.testing import eq_

m1 = MetaData()
t1= Table('foo', m1, Column('value', Boolean))

m2 = MetaData()
t2 = t1.tometadata(m2)

dialect = postgresql.dialect()

eq_(
    str(schema.CreateTable(t1).compile(dialect=dialect)),
    str(schema.CreateTable(t2).compile(dialect=dialect))

)

#AssertionError: '\nCREATE TABLE foo (\n\tvalue BOOLEAN\n)\n\n' != '\nCREATE TABLE foo (\n\tvalue BOOLEAN, \n\tCHECK (value IN (0, 1))\n)\n\n'

Comments (2)

  1. Log in to comment