diff options
Diffstat (limited to 'test/sql/test_constraints.py')
-rw-r--r-- | test/sql/test_constraints.py | 43 |
1 files changed, 42 insertions, 1 deletions
diff --git a/test/sql/test_constraints.py b/test/sql/test_constraints.py index 5ea5a7eda..546a14ca2 100644 --- a/test/sql/test_constraints.py +++ b/test/sql/test_constraints.py @@ -437,7 +437,8 @@ class ConstraintCompilationTest(fixtures.TestBase, AssertsCompiledSQL): ) constraint = CheckConstraint('a < b',name="my_test_constraint", - deferrable=True,initially='DEFERRED', table=t) + deferrable=True,initially='DEFERRED', + table=t) # before we create an AddConstraint, @@ -513,4 +514,44 @@ class ConstraintCompilationTest(fixtures.TestBase, AssertsCompiledSQL): "ALTER TABLE tbl ADD PRIMARY KEY (a)" ) + def test_auto_append_constraint(self): + m = MetaData() + + t = Table('tbl', m, + Column('a', Integer), + Column('b', Integer) + ) + + t2 = Table('t2', m, + Column('a', Integer), + Column('b', Integer) + ) + + for c in ( + UniqueConstraint(t.c.a), + CheckConstraint(t.c.a > 5), + ForeignKeyConstraint([t.c.a], [t2.c.a]), + PrimaryKeyConstraint(t.c.a) + ): + assert c in t.constraints + t.append_constraint(c) + assert c in t.constraints + c = Index('foo', t.c.a) + assert c in t.indexes + + def test_ambig_check_constraint_auto_append(self): + m = MetaData() + + t = Table('tbl', m, + Column('a', Integer), + Column('b', Integer) + ) + + t2 = Table('t2', m, + Column('a', Integer), + Column('b', Integer) + ) + c = CheckConstraint(t.c.a > t2.c.b) + assert c not in t.constraints + assert c not in t2.constraints
\ No newline at end of file |