diff options
| author | Nick Pope <nick@nickpope.me.uk> | 2021-05-28 23:56:23 +0100 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2021-10-01 13:11:37 +0200 |
| commit | c2f6c05c4cc73e831b7e852eb58bd6d7a83fa46c (patch) | |
| tree | d88631488b481873d6b0b3096454f6d4e9e0a071 /django | |
| parent | e76f9d5b443845639262e18d9020ef4b070f1c7d (diff) | |
Refs #32943 -- Added support for covering exclusion constraints using SP-GiST indexes on PostgreSQL 14+.
Diffstat (limited to 'django')
| -rw-r--r-- | django/contrib/postgres/constraints.py | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/django/contrib/postgres/constraints.py b/django/contrib/postgres/constraints.py index a670628d8a..3b12098fe9 100644 --- a/django/contrib/postgres/constraints.py +++ b/django/contrib/postgres/constraints.py @@ -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 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 require PostgreSQL 12+.' + 'Covering exclusion constraints using an SP-GiST index ' + 'require PostgreSQL 14+.' ) def deconstruct(self): |
