summaryrefslogtreecommitdiff
path: root/tests/introspection
diff options
context:
space:
mode:
authorSaulius Žemaitaitis <saulius@zemaitaitis.lt>2016-11-05 13:46:59 +0100
committerTim Graham <timograham@gmail.com>2016-11-06 10:13:32 +0100
commitf28d29e8b726b8b013e8739fab542a796f348e78 (patch)
tree2cf21868e04c30c91a15eb25a5a220bf7dd52d84 /tests/introspection
parent09da1e79de5a03a63610822bd4e5fc2adcbeb38a (diff)
downloaddjango-f28d29e8b726b8b013e8739fab542a796f348e78.tar.gz
Fixed #27372 -- Fixed introspection of SQLite foreign keys with spaces in DDL.
Thanks samuller for the report and initial patch.
Diffstat (limited to 'tests/introspection')
-rw-r--r--tests/introspection/tests.py24
1 files changed, 13 insertions, 11 deletions
diff --git a/tests/introspection/tests.py b/tests/introspection/tests.py
index 7c60902deb..7bee998043 100644
--- a/tests/introspection/tests.py
+++ b/tests/introspection/tests.py
@@ -143,17 +143,19 @@ class IntrospectionTests(TransactionTestCase):
@skipUnless(connection.vendor == 'sqlite', "This is an sqlite-specific issue")
def test_get_relations_alt_format(self):
- """With SQLite, foreign keys can be added with different syntaxes."""
- with connection.cursor() as cursor:
- cursor.fetchone = mock.Mock(
- return_value=[
- "CREATE TABLE track(id, art_id INTEGER, FOREIGN KEY(art_id) REFERENCES {}(id));".format(
- Article._meta.db_table
- )
- ]
- )
- relations = connection.introspection.get_relations(cursor, 'mocked_table')
- self.assertEqual(relations, {'art_id': ('id', Article._meta.db_table)})
+ """
+ With SQLite, foreign keys can be added with different syntaxes and
+ formatting.
+ """
+ create_table_statements = [
+ "CREATE TABLE track(id, art_id INTEGER, FOREIGN KEY(art_id) REFERENCES {}(id));",
+ "CREATE TABLE track(id, art_id INTEGER, FOREIGN KEY (art_id) REFERENCES {}(id));"
+ ]
+ for statement in create_table_statements:
+ with connection.cursor() as cursor:
+ cursor.fetchone = mock.Mock(return_value=[statement.format(Article._meta.db_table)])
+ relations = connection.introspection.get_relations(cursor, 'mocked_table')
+ self.assertEqual(relations, {'art_id': ('id', Article._meta.db_table)})
@skipUnlessDBFeature('can_introspect_foreign_keys')
def test_get_key_columns(self):