summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/dialect/test_sqlite.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/test/dialect/test_sqlite.py b/test/dialect/test_sqlite.py
index 33903ff89..314825a19 100644
--- a/test/dialect/test_sqlite.py
+++ b/test/dialect/test_sqlite.py
@@ -1134,6 +1134,16 @@ class ConstraintReflectionTest(fixtures.TestBase):
# will contain an "autoindex"
conn.execute("create table o (foo varchar(20) primary key)")
+ conn.execute(
+ "CREATE TABLE p (id INTEGER PRIMARY KEY, "
+ "c1 INTEGER, c2 INTEGER, c3 INTEGER, "
+ "CONSTRAINT fk1 FOREIGN KEY (c1) REFERENCES a1(id) "
+ "ON DELETE SET NULL, "
+ "CONSTRAINT fk2 FOREIGN KEY (c2) REFERENCES a1(id) "
+ "ON UPDATE CASCADE, "
+ "CONSTRAINT fk3 FOREIGN KEY (c3) REFERENCES a2(id) "
+ "ON DELETE CASCADE ON UPDATE SET NULL)"
+ )
@classmethod
def teardown_class(cls):
@@ -1266,6 +1276,33 @@ class ConstraintReflectionTest(fixtures.TestBase):
'constrained_columns': ['q', 'p']}]
)
+ def test_foreign_key_ondelete_onupdate(self):
+ inspector = Inspector(testing.db)
+ fks = inspector.get_foreign_keys('p')
+ eq_(
+ fks,
+ [
+ {
+ 'referred_table': 'a1', 'referred_columns': ['id'],
+ 'referred_schema': None, 'name': 'fk1',
+ 'constrained_columns': ['c1'],
+ 'options': {'ondelete': 'SET NULL'}
+ },
+ {
+ 'referred_table': 'a1', 'referred_columns': ['id'],
+ 'referred_schema': None, 'name': 'fk2',
+ 'constrained_columns': ['c2'],
+ 'options': {'onupdate': 'CASCADE'}
+ },
+ {
+ 'referred_table': 'a2', 'referred_columns': ['id'],
+ 'referred_schema': None, 'name': 'fk3',
+ 'constrained_columns': ['c3'],
+ 'options': {'ondelete': 'CASCADE', 'onupdate': 'SET NULL'}
+ },
+ ]
+ )
+
def test_dont_reflect_autoindex(self):
inspector = Inspector(testing.db)
eq_(inspector.get_indexes('o'), [])