summaryrefslogtreecommitdiff
path: root/test/sql/test_constraints.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2012-06-21 15:39:48 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2012-06-21 15:39:48 -0400
commit2272f30af435c5283157724bbb16fb0a573159ce (patch)
treea74af95302914877bbc3a81f23cca15bdec1d731 /test/sql/test_constraints.py
parent81eefb2f13a9c854e1dcd924550d0c36553e930a (diff)
downloadsqlalchemy-2272f30af435c5283157724bbb16fb0a573159ce.tar.gz
- [feature] Added "MATCH" clause to ForeignKey,
ForeignKeyConstraint, courtesy Ryan Kelly. [ticket:2502]
Diffstat (limited to 'test/sql/test_constraints.py')
-rw-r--r--test/sql/test_constraints.py21
1 files changed, 20 insertions, 1 deletions
diff --git a/test/sql/test_constraints.py b/test/sql/test_constraints.py
index 546a14ca2..fcc6c085e 100644
--- a/test/sql/test_constraints.py
+++ b/test/sql/test_constraints.py
@@ -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 \ No newline at end of file
+ assert c not in t2.constraints