From fbcd7df12094f1b3addb6a531aa5da0639768623 Mon Sep 17 00:00:00 2001 From: Nick Pope Date: Fri, 1 Oct 2021 08:33:27 +0200 Subject: [PATCH] [4.0.x] Fixed SpGistIndex tests on PostgreSQL 14+. Backport of dd26362f6312e7ba7b04099b5285d8e1d2900e63 from main --- tests/postgres_tests/test_indexes.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/tests/postgres_tests/test_indexes.py b/tests/postgres_tests/test_indexes.py index a212de2087..f449dbbb76 100644 --- a/tests/postgres_tests/test_indexes.py +++ b/tests/postgres_tests/test_indexes.py @@ -492,31 +492,31 @@ class SchemaTests(PostgreSQLTestCase): def test_spgist_index(self): # Ensure the table is there and doesn't have an index. - self.assertNotIn('field', self.get_constraints(CharFieldModel._meta.db_table)) + self.assertNotIn('field', self.get_constraints(TextFieldModel._meta.db_table)) # Add the index. - index_name = 'char_field_model_field_spgist' + index_name = 'text_field_model_field_spgist' index = SpGistIndex(fields=['field'], name=index_name) with connection.schema_editor() as editor: - editor.add_index(CharFieldModel, index) - constraints = self.get_constraints(CharFieldModel._meta.db_table) + editor.add_index(TextFieldModel, index) + constraints = self.get_constraints(TextFieldModel._meta.db_table) # The index was added. self.assertEqual(constraints[index_name]['type'], SpGistIndex.suffix) # Drop the index. with connection.schema_editor() as editor: - editor.remove_index(CharFieldModel, index) - self.assertNotIn(index_name, self.get_constraints(CharFieldModel._meta.db_table)) + editor.remove_index(TextFieldModel, index) + self.assertNotIn(index_name, self.get_constraints(TextFieldModel._meta.db_table)) def test_spgist_parameters(self): - index_name = 'integer_array_spgist_fillfactor' + index_name = 'text_field_model_spgist_fillfactor' index = SpGistIndex(fields=['field'], name=index_name, fillfactor=80) with connection.schema_editor() as editor: - editor.add_index(CharFieldModel, index) - constraints = self.get_constraints(CharFieldModel._meta.db_table) + editor.add_index(TextFieldModel, index) + constraints = self.get_constraints(TextFieldModel._meta.db_table) self.assertEqual(constraints[index_name]['type'], SpGistIndex.suffix) self.assertEqual(constraints[index_name]['options'], ['fillfactor=80']) with connection.schema_editor() as editor: - editor.remove_index(CharFieldModel, index) - self.assertNotIn(index_name, self.get_constraints(CharFieldModel._meta.db_table)) + editor.remove_index(TextFieldModel, index) + self.assertNotIn(index_name, self.get_constraints(TextFieldModel._meta.db_table)) def test_op_class(self): index_name = 'test_op_class'