mirror of
https://github.com/django/django.git
synced 2025-11-25 05:04:26 +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:
parent
eba4197c71
commit
a18e43c5bb
7 changed files with 66 additions and 56 deletions
|
|
@ -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."""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue