mirror of
https://github.com/django/django.git
synced 2025-10-24 14:16:09 +00:00
Made get_indexes() consistent across backends.
Fixed #15933, #18082 -- the get_indexes() method introspection was done inconsitently depending on the backend. For example SQLite included all the columns in the table in the returned dictionary, while MySQL introspected also multicolumn indexes. All backends return now consistenly only single-column indexes. Thanks to andi for the MySQL report, and ikelly for comments on Oracle's get_indexes() changes.
This commit is contained in:
@@ -137,6 +137,15 @@ class IntrospectionTests(TestCase):
|
||||
indexes = connection.introspection.get_indexes(cursor, Article._meta.db_table)
|
||||
self.assertEqual(indexes['reporter_id'], {'unique': False, 'primary_key': False})
|
||||
|
||||
def test_get_indexes_multicol(self):
|
||||
"""
|
||||
Test that multicolumn indexes are not included in the introspection
|
||||
results.
|
||||
"""
|
||||
cursor = connection.cursor()
|
||||
indexes = connection.introspection.get_indexes(cursor, Reporter._meta.db_table)
|
||||
self.assertNotIn('first_name', indexes)
|
||||
self.assertIn('id', indexes)
|
||||
|
||||
def datatype(dbtype, description):
|
||||
"""Helper to convert a data type into a string."""
|
||||
|
||||
Reference in New Issue
Block a user