summaryrefslogtreecommitdiff
path: root/tests/introspection
diff options
context:
space:
mode:
authorSimon Charette <charette.s@gmail.com>2021-11-13 14:43:04 -0500
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2021-11-15 08:07:07 +0100
commit483e30c3d5c82c562a17e016ae2098666bf3a728 (patch)
tree3b0fd9093b01ef5eb95e0746d398cb88ab858ff7 /tests/introspection
parent30ec7fe89ac6966c45da11a646553b699cd38624 (diff)
downloaddjango-483e30c3d5c82c562a17e016ae2098666bf3a728.tar.gz
Fixed #33288 -- Made SQLite introspection use information schema for relations.
Previous solution was using brittle and complex parsing rules to extract them from the SQL used to define the tables. Removed a now unnecessary unit test that ensured the removed parsing logic accounted for optional spacing.
Diffstat (limited to 'tests/introspection')
-rw-r--r--tests/introspection/tests.py18
1 files changed, 0 insertions, 18 deletions
diff --git a/tests/introspection/tests.py b/tests/introspection/tests.py
index b55714f93e..d138e71bd6 100644
--- a/tests/introspection/tests.py
+++ b/tests/introspection/tests.py
@@ -1,5 +1,3 @@
-from unittest import mock, skipUnless
-
from django.db import DatabaseError, connection
from django.db.models import Index
from django.test import TransactionTestCase, skipUnlessDBFeature
@@ -152,22 +150,6 @@ class IntrospectionTests(TransactionTestCase):
editor.add_field(Article, body)
self.assertEqual(relations, expected_relations)
- @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 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), 'table'])
- relations = connection.introspection.get_relations(cursor, 'mocked_table')
- self.assertEqual(relations, {'art_id': ('id', Article._meta.db_table)})
-
def test_get_primary_key_column(self):
with connection.cursor() as cursor:
primary_key_column = connection.introspection.get_primary_key_column(cursor, Article._meta.db_table)