summaryrefslogtreecommitdiff
path: root/test/dialect/test_sqlite.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2012-01-07 15:37:51 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2012-01-07 15:37:51 -0500
commita4a81f7b962102ba1ed3a60d9ac52c62a57c4458 (patch)
treeacce2086f48385fd400ef4c9b50b3a2d64b7543b /test/dialect/test_sqlite.py
parent74e00ed0fa3d9ade12b9076cc2e59b5ecf4886bb (diff)
downloadsqlalchemy-a4a81f7b962102ba1ed3a60d9ac52c62a57c4458.tar.gz
- [bug] the "name" of an FK constraint in SQLite
is reflected as "None", not "0" [ticket:2364]. SQLite does not appear to support constraint naming in any case (the names are ignored).
Diffstat (limited to 'test/dialect/test_sqlite.py')
-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 c4748500a..ed9d7e493 100644
--- a/test/dialect/test_sqlite.py
+++ b/test/dialect/test_sqlite.py
@@ -728,4 +728,41 @@ class ReflectHeadlessFKsTest(fixtures.TestBase):
assert b.c.id.references(a.c.id)
+class ReflectFKConstraintTest(fixtures.TestBase):
+ __only_on__ = 'sqlite'
+ def setup(self):
+ testing.db.execute("CREATE TABLE a (id INTEGER PRIMARY KEY)")
+ testing.db.execute("CREATE TABLE b (id INTEGER PRIMARY KEY, "
+ "FOREIGN KEY(id) REFERENCES a(id))")
+ testing.db.execute("CREATE TABLE c (id INTEGER, "
+ "CONSTRAINT bar PRIMARY KEY(id),"
+ "CONSTRAINT foo FOREIGN KEY(id) REFERENCES a(id))")
+
+ def teardown(self):
+ testing.db.execute("drop table c")
+ testing.db.execute("drop table b")
+ testing.db.execute("drop table a")
+
+ def test_name_is_none(self):
+ # and not "0"
+ meta = MetaData()
+ b = Table('b', meta, autoload=True, autoload_with=testing.db)
+ eq_(
+ [con.name for con in b.constraints],
+ [None, None]
+ )
+
+ def test_name_not_none(self):
+ # we don't have names for PK constraints,
+ # it appears we get back None in the pragma for
+ # FKs also (also it doesn't even appear to be documented on sqlite's docs
+ # at http://www.sqlite.org/pragma.html#pragma_foreign_key_list
+ # how did we ever know that's the "name" field ??)
+
+ meta = MetaData()
+ c = Table('c', meta, autoload=True, autoload_with=testing.db)
+ eq_(
+ set([con.name for con in c.constraints]),
+ set([None, None])
+ )