mirror of
https://github.com/django/django.git
synced 2025-07-16 17:55:18 +00:00
Fixed #27097 -- Added index type introspection to built-in db backends.
This commit is contained in:
parent
082f5bfdbc
commit
dbccf163b6
8 changed files with 23 additions and 20 deletions
|
@ -44,13 +44,14 @@ class SchemaTests(PostgreSQLTestCase):
|
|||
# Ensure the table is there and doesn't have an index.
|
||||
self.assertNotIn('field', self.get_constraints(IntegerArrayModel._meta.db_table))
|
||||
# Add the index
|
||||
index = GinIndex(fields=['field'], name='integer_array_model_field_gin')
|
||||
index_name = 'integer_array_model_field_gin'
|
||||
index = GinIndex(fields=['field'], name=index_name)
|
||||
with connection.schema_editor() as editor:
|
||||
editor.add_index(IntegerArrayModel, index)
|
||||
self.assertIn('integer_array_model_field_gin', self.get_constraints(IntegerArrayModel._meta.db_table))
|
||||
constraints = self.get_constraints(IntegerArrayModel._meta.db_table)
|
||||
self.assertEqual(constraints['integer_array_model_field_gin']['type'], 'gin')
|
||||
# Check gin index was added
|
||||
self.assertEqual(constraints[index_name]['type'], 'gin')
|
||||
# Drop the index
|
||||
with connection.schema_editor() as editor:
|
||||
editor.remove_index(IntegerArrayModel, index)
|
||||
self.assertNotIn('integer_array_model_field_gin', self.get_constraints(IntegerArrayModel._meta.db_table))
|
||||
self.assertNotIn(index_name, self.get_constraints(IntegerArrayModel._meta.db_table))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue