Opened 8 years ago
Closed 8 years ago
#27935 closed Bug (fixed)
BrinIndex crashes if name > 30 characters
Reported by: | Den | Owned by: | |
---|---|---|---|
Component: | contrib.postgres | Version: | 1.11 |
Severity: | Release blocker | Keywords: | |
Cc: | felisiak.mariusz@… | Triage Stage: | Accepted |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
BrinIndex.suffix ( django.contrib.postgres.indexes) longer 3 char, but Index.set_name_with_model method allowed 3 char in suffix
AssertionError: Index too long for multiple database support. Is self.suffix longer than 3 characters?
Change History (11)
comment:1 by , 8 years ago
Severity: | Normal → Release blocker |
---|---|
Triage Stage: | Unreviewed → Accepted |
comment:2 by , 8 years ago
Cc: | added |
---|
comment:3 by , 8 years ago
The current model wasn't actually enough to trigger a failure for the auto-generated name as the length of the indexed field is only 5 characters.
Either changing suffix = brin
to suffix = brn
, or removing a character from the hash so it's just five characters. Probably the first is better?
def test_name_auto_generation_fail(self): # name of field must be at least 7 characters long to get to 30 characters index = BrinIndex(fields=['datetimes']) index.set_name_with_model(DateTimeArrayModel) self.assertEqual(index.name, 'postgres_te_datetim_b1e2ca_brn')
comment:5 by , 8 years ago
Summary: | BrinIndex.suffix for postgres longer 3 char → BrinIndex crashes if name > 30 characters |
---|---|
Triage Stage: | Accepted → Ready for checkin |
comment:8 by , 8 years ago
Has patch: | unset |
---|---|
Resolution: | fixed |
Status: | closed → new |
Triage Stage: | Ready for checkin → Accepted |
Florian pointed out on IRC that in a mixed database setup, connection.ops.max_name_length()
won't necessarily be a PostgreSQL connection. Maybe that could use the db.backends.postgresql.operations.DatabaseOperations
class instead.
comment:11 by , 8 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
There are no tests for auto-generated index names as there are for GinIndex: https://github.com/django/django/blob/master/tests/postgres_tests/test_indexes.py#L61-L64