Do not test foreign keys with SQLite version < 3.7

Fixes bug 1158828

Even though SQLAlchemy is documented to support foreign keys (with
the pragma set) on SQLite >= 3.6.19, we're seeing consistent problems
with that support on RHEL 6.4 with SQLite 3.6.20.  It works fine on
Fedora and Ubuntu with SQLite 3.7.x.

To work around these problems, if we're using SQLite, test the SQLite
version inside the test that requires foreign key support,
and skip the test if it's < 3.7

Change-Id: I1c26f29371376b271a4e384ea7b5d2009651acc1
This commit is contained in:
David Ripton
2013-03-25 10:30:06 -04:00
parent 8058daf65f
commit 66a1338f78

View File

@@ -2516,6 +2516,15 @@ class ArchiveTestCase(test.TestCase):
# SQLite doesn't enforce foreign key constraints without a pragma.
dialect = self.engine.url.get_dialect()
if dialect == sqlite.dialect:
# We're seeing issues with foreign key support in SQLite 3.6.20
# SQLAlchemy doesn't support it at all with < SQLite 3.6.19
# It works fine in SQLite 3.7.
# So return early to skip this test if running SQLite < 3.7
import sqlite3
tup = sqlite3.sqlite_version_info
if tup[0] < 3 or (tup[0] == 3 and tup[1] < 7):
self.skipTest(
'sqlite version too old for reliable SQLA foreign_keys')
self.conn.execute("PRAGMA foreign_keys = ON")
insert_statement = self.console_pools.insert().values(deleted=1)
result = self.conn.execute(insert_statement)