summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMariusz Felisiak <felisiak.mariusz@gmail.com>2017-03-20 16:21:01 +0100
committerTim Graham <timograham@gmail.com>2017-03-20 11:21:01 -0400
commit2867b7eb4b8477710f11707d4b975db10e5f91a7 (patch)
treed337c0f57ab3c8bca5bb2ae07a18466268aa50ec
parent6cb0a3ac2836c044987f7a0cca0d1e99d52e002e (diff)
Refs #27935 -- Fixed BrinIndex.max_name_length if a project's default database isn't PostgreSQL.
Thanks Florian Apolloner for the report.
-rw-r--r--django/contrib/postgres/indexes.py15
1 files changed, 5 insertions, 10 deletions
diff --git a/django/contrib/postgres/indexes.py b/django/contrib/postgres/indexes.py
index feb7053ed8..42215dfdce 100644
--- a/django/contrib/postgres/indexes.py
+++ b/django/contrib/postgres/indexes.py
@@ -1,12 +1,15 @@
-from django.db import connection
from django.db.models import Index
-from django.utils.functional import cached_property
__all__ = ['BrinIndex', 'GinIndex']
class BrinIndex(Index):
suffix = 'brin'
+ # Allow an index name longer than 30 characters since the suffix is 4
+ # characters (usual limit is 3). Since this index can only be used on
+ # PostgreSQL, the 30 character limit for cross-database compatibility isn't
+ # applicable.
+ max_name_length = 31
def __init__(self, fields=[], name=None, pages_per_range=None):
if pages_per_range is not None and pages_per_range <= 0:
@@ -36,14 +39,6 @@ class BrinIndex(Index):
schema_editor.quote_value(self.pages_per_range)) + parameters['extra']
return parameters
- @cached_property
- def max_name_length(self):
- # Allow an index name longer than 30 characters since the suffix
- # is 4 characters (usual limit is 3). Since this index can only be
- # used on PostgreSQL, the 30 character limit for cross-database
- # compatibility isn't applicable.
- return connection.ops.max_name_length()
-
class GinIndex(Index):
suffix = 'gin'