summaryrefslogtreecommitdiff
path: root/tests/postgres_tests/test_indexes.py
diff options
context:
space:
mode:
authorMads Jensen <mje@inducks.org>2017-05-30 23:17:32 +0200
committerTim Graham <timograham@gmail.com>2017-06-20 10:54:39 -0400
commitde42adf4ff6b80e25bbd9e70070146ef15076a83 (patch)
tree2ea9366801b8e9c6bfdb62cad8460249a5fe48f3 /tests/postgres_tests/test_indexes.py
parent2503ad51549ffa60468b80b9c99d3e54c744be4f (diff)
Fixed #27869 -- Added fastupdate and gin_pending_list_limit params to GinIndex.
Thanks Tim Graham and Markus Holtermann for review.
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'