Refs #27869 -- Added PostgreSQL version check for GinIndex support.
This commit is contained in:
parent
ff9543b351
commit
743d28f553
|
@ -105,6 +105,10 @@ class GinIndex(PostgresIndex):
|
||||||
kwargs['gin_pending_list_limit'] = self.gin_pending_list_limit
|
kwargs['gin_pending_list_limit'] = self.gin_pending_list_limit
|
||||||
return path, args, kwargs
|
return path, args, kwargs
|
||||||
|
|
||||||
|
def check_supported(self, schema_editor):
|
||||||
|
if self.gin_pending_list_limit and not schema_editor.connection.features.has_gin_pending_list_limit:
|
||||||
|
raise NotSupportedError('GIN option gin_pending_list_limit requires PostgreSQL 9.5+.')
|
||||||
|
|
||||||
def get_with_params(self):
|
def get_with_params(self):
|
||||||
with_params = []
|
with_params = []
|
||||||
if self.gin_pending_list_limit is not None:
|
if self.gin_pending_list_limit is not None:
|
||||||
|
|
|
@ -185,6 +185,16 @@ class SchemaTests(PostgreSQLTestCase):
|
||||||
editor.remove_index(IntegerArrayModel, index)
|
editor.remove_index(IntegerArrayModel, index)
|
||||||
self.assertNotIn(index_name, self.get_constraints(IntegerArrayModel._meta.db_table))
|
self.assertNotIn(index_name, self.get_constraints(IntegerArrayModel._meta.db_table))
|
||||||
|
|
||||||
|
def test_gin_parameters_exception(self):
|
||||||
|
index_name = 'gin_options_exception'
|
||||||
|
index = GinIndex(fields=['field'], name=index_name, gin_pending_list_limit=64)
|
||||||
|
msg = 'GIN option gin_pending_list_limit requires PostgreSQL 9.5+.'
|
||||||
|
with self.assertRaisesMessage(NotSupportedError, msg):
|
||||||
|
with mock.patch('django.db.connection.features.has_gin_pending_list_limit', False):
|
||||||
|
with connection.schema_editor() as editor:
|
||||||
|
editor.add_index(IntegerArrayModel, index)
|
||||||
|
self.assertNotIn(index_name, self.get_constraints(IntegerArrayModel._meta.db_table))
|
||||||
|
|
||||||
@skipUnlessDBFeature('has_brin_index_support')
|
@skipUnlessDBFeature('has_brin_index_support')
|
||||||
def test_brin_index(self):
|
def test_brin_index(self):
|
||||||
index_name = 'char_field_model_field_brin'
|
index_name = 'char_field_model_field_brin'
|
||||||
|
|
Loading…
Reference in New Issue