summaryrefslogtreecommitdiff
path: root/tests/postgres_tests/test_indexes.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/postgres_tests/test_indexes.py')
-rw-r--r--tests/postgres_tests/test_indexes.py42
1 files changed, 40 insertions, 2 deletions
diff --git a/tests/postgres_tests/test_indexes.py b/tests/postgres_tests/test_indexes.py
index c3172f3a49..d866a8b869 100644
--- a/tests/postgres_tests/test_indexes.py
+++ b/tests/postgres_tests/test_indexes.py
@@ -65,11 +65,24 @@ class GinIndexTests(PostgreSQLTestCase):
self.assertEqual(index.name, 'postgres_te_field_def2f8_gin')
def test_deconstruction(self):
- index = GinIndex(fields=['title'], name='test_title_gin')
+ index = GinIndex(
+ fields=['title'],
+ name='test_title_gin',
+ fastupdate=True,
+ gin_pending_list_limit=128,
+ )
path, args, kwargs = index.deconstruct()
self.assertEqual(path, 'django.contrib.postgres.indexes.GinIndex')
self.assertEqual(args, ())
- self.assertEqual(kwargs, {'fields': ['title'], 'name': 'test_title_gin'})
+ self.assertEqual(
+ kwargs,
+ {
+ 'fields': ['title'],
+ 'name': 'test_title_gin',
+ 'fastupdate': True,
+ 'gin_pending_list_limit': 128,
+ }
+ )
class SchemaTests(PostgreSQLTestCase):
@@ -97,6 +110,31 @@ class SchemaTests(PostgreSQLTestCase):
editor.remove_index(IntegerArrayModel, index)
self.assertNotIn(index_name, self.get_constraints(IntegerArrayModel._meta.db_table))
+ def test_gin_fastupdate(self):
+ index_name = 'integer_array_gin_fastupdate'
+ index = GinIndex(fields=['field'], name=index_name, fastupdate=False)
+ with connection.schema_editor() as editor:
+ editor.add_index(IntegerArrayModel, index)
+ constraints = self.get_constraints(IntegerArrayModel._meta.db_table)
+ self.assertEqual(constraints[index_name]['type'], 'gin')
+ self.assertEqual(constraints[index_name]['options'], ['fastupdate=off'])
+ with connection.schema_editor() as editor:
+ editor.remove_index(IntegerArrayModel, index)
+ self.assertNotIn(index_name, self.get_constraints(IntegerArrayModel._meta.db_table))
+
+ @skipUnlessDBFeature('has_gin_pending_list_limit')
+ def test_gin_parameters(self):
+ index_name = 'integer_array_gin_params'
+ index = GinIndex(fields=['field'], name=index_name, fastupdate=True, gin_pending_list_limit=64)
+ with connection.schema_editor() as editor:
+ editor.add_index(IntegerArrayModel, index)
+ constraints = self.get_constraints(IntegerArrayModel._meta.db_table)
+ self.assertEqual(constraints[index_name]['type'], 'gin')
+ self.assertEqual(constraints[index_name]['options'], ['gin_pending_list_limit=64', 'fastupdate=on'])
+ with connection.schema_editor() as editor:
+ editor.remove_index(IntegerArrayModel, index)
+ self.assertNotIn(index_name, self.get_constraints(IntegerArrayModel._meta.db_table))
+
@skipUnlessDBFeature('has_brin_index_support')
def test_brin_index(self):
index_name = 'char_field_model_field_brin'