Refs #32943 -- Added support for covering exclusion constraints using SP-GiST indexes on PostgreSQL 14+.

This commit is contained in:
Nick Pope 2021-05-28 23:56:23 +01:00 committed by Mariusz Felisiak
parent e76f9d5b44
commit c2f6c05c4c
4 changed files with 131 additions and 29 deletions

View file

@ -45,10 +45,6 @@ class ExclusionConstraint(BaseConstraint):
raise ValueError(
'ExclusionConstraint.include must be a list or tuple.'
)
if include and index_type and index_type.lower() != 'gist':
raise ValueError(
'Covering exclusion constraints only support GiST indexes.'
)
if not isinstance(opclasses, (list, tuple)):
raise ValueError(
'ExclusionConstraint.opclasses must be a list or tuple.'
@ -124,9 +120,23 @@ class ExclusionConstraint(BaseConstraint):
)
def check_supported(self, schema_editor):
if self.include and not schema_editor.connection.features.supports_covering_gist_indexes:
if (
self.include and
self.index_type.lower() == 'gist' and
not schema_editor.connection.features.supports_covering_gist_indexes
):
raise NotSupportedError(
'Covering exclusion constraints require PostgreSQL 12+.'
'Covering exclusion constraints using a GiST index require '
'PostgreSQL 12+.'
)
if (
self.include and
self.index_type.lower() == 'spgist' and
not schema_editor.connection.features.supports_covering_spgist_indexes
):
raise NotSupportedError(
'Covering exclusion constraints using an SP-GiST index '
'require PostgreSQL 14+.'
)
def deconstruct(self):