- [feature] Added "MATCH" clause to ForeignKey,

ForeignKeyConstraint, courtesy Ryan Kelly.
[ticket:2502]
This commit is contained in:
Mike Bayer
2012-06-21 15:39:48 -04:00
parent 81eefb2f13
commit 2272f30af4
4 changed files with 50 additions and 6 deletions
+20 -1
View File
@@ -355,6 +355,25 @@ class ConstraintCompilationTest(fixtures.TestBase, AssertsCompiledSQL):
"(a) DEFERRABLE INITIALLY DEFERRED)",
)
def test_fk_match_clause(self):
t = Table('tbl', MetaData(),
Column('a', Integer),
Column('b', Integer,
ForeignKey('tbl.a', match="SIMPLE")))
self.assert_compile(
schema.CreateTable(t),
"CREATE TABLE tbl (a INTEGER, b INTEGER, "
"FOREIGN KEY(b) REFERENCES tbl "
"(a) MATCH SIMPLE)",
)
self.assert_compile(
schema.AddConstraint(list(t.foreign_keys)[0].constraint),
"ALTER TABLE tbl ADD FOREIGN KEY(b) "
"REFERENCES tbl (a) MATCH SIMPLE"
)
def test_deferrable_unique(self):
factory = lambda **kw: UniqueConstraint('b', **kw)
self._test_deferrable(factory)
@@ -554,4 +573,4 @@ class ConstraintCompilationTest(fixtures.TestBase, AssertsCompiledSQL):
)
c = CheckConstraint(t.c.a > t2.c.b)
assert c not in t.constraints
assert c not in t2.constraints
assert c not in t2.constraints