mirror of
https://github.com/sqlalchemy/sqlalchemy.git
synced 2026-05-16 13:47:20 -04:00
- [feature] Added "MATCH" clause to ForeignKey,
ForeignKeyConstraint, courtesy Ryan Kelly. [ticket:2502]
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user