mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Refs #20888 -- Added index order introspection.
This commit is contained in:
@@ -182,6 +182,26 @@ class IntrospectionTests(TransactionTestCase):
|
||||
self.assertNotIn('first_name', indexes)
|
||||
self.assertIn('id', indexes)
|
||||
|
||||
@skipUnlessDBFeature('supports_index_column_ordering')
|
||||
def test_get_constraints_indexes_orders(self):
|
||||
"""
|
||||
Indexes have the 'orders' key with a list of 'ASC'/'DESC' values.
|
||||
"""
|
||||
with connection.cursor() as cursor:
|
||||
constraints = connection.introspection.get_constraints(cursor, Article._meta.db_table)
|
||||
indexes_verified = 0
|
||||
expected_columns = [
|
||||
['reporter_id'],
|
||||
['headline', 'pub_date'],
|
||||
['response_to_id'],
|
||||
]
|
||||
for key, val in constraints.items():
|
||||
if val['index'] and not (val['primary_key'] or val['unique']):
|
||||
self.assertIn(val['columns'], expected_columns)
|
||||
self.assertEqual(val['orders'], ['ASC'] * len(val['columns']))
|
||||
indexes_verified += 1
|
||||
self.assertEqual(indexes_verified, 3)
|
||||
|
||||
|
||||
def datatype(dbtype, description):
|
||||
"""Helper to convert a data type into a string."""
|
||||
|
||||
Reference in New Issue
Block a user