#31881: Raise Index name limit for postgres -------------------------------------+------------------------------------- Reporter: Jarek Glowacki | Owner: nobody Type: | Status: closed Cleanup/optimization | Component: Database layer | Version: master (models, ORM) | Severity: Normal | Resolution: needsinfo Keywords: postgres index | Triage Stage: max_name_length | Unreviewed Has patch: 0 | Needs documentation: 0 Needs tests: 0 | Patch needs improvement: 0 Easy pickings: 0 | UI/UX: 0 -------------------------------------+-------------------------------------
Comment (by Jarek Glowacki): Hey sorry for the slow response. Replying to [comment:1 felixxm]: > This will break backwards compatibility for `PostgresIndex` subclasses with long suffixes, because currently we allow suffixes of any length. I had a deeper dig and I don't see how that's the case.. `max_name_length` is ''only'' interrogated when: - an index name has been automatically constructed: https://github.com/django/django/blob/8c7992f658e1125f8dc20b19206e8bbbe4187372/django/db/models/indexes.py#L118-L121 - system checks run: https://github.com/django/django/blob/8c7992f658e1125f8dc20b19206e8bbbe4187372/django/db/models/base.py#L1604-L1612 The code that automatically generates indexes would remain untouched, and unaffected: https://github.com/django/django/blob/8c7992f658e1125f8dc20b19206e8bbbe4187372/django/db/models/indexes.py#L110-L117 It could potentially be relaxed to pad out the hash up to `MyIndex.max_name_length`, but I'm not suggesting we change this, and I don't think doing so would provide any benefit. I've gone ahead and implemented the change here: https://github.com/django/django/compare/master...jarekwg:ticket_31881?expand=1 Please note that `PostgresIndex` isn't used by default for Postgres backends, it's only used when inherited by those special Postgres-specific Indexes. So the solution I'm suggesting would only help in cases where users explicitly specify `PostgresIndex` when defining their custom Indexes. Users with custom overrides would still be overriding all this, so I don't see how they'd run into regressions. The only hardcoded shenanigans i could find that would have trouble if suffix length were to change is the one here, but it's oracle-specific code, so wouldn't be affected by our work anyway: https://github.com/django/django/blob/8c7992f658e1125f8dc20b19206e8bbbe4187372/django/db/backends/oracle/operations.py#L596 All that said, I agree that documenting `suffix` and `max_name_length` would also be quite helpful. I wouldn't've opened this ticket had there been a note in the docs, instructing me to create my own index class with these attributes. I'm happy to offer a PR for that too. -- Ticket URL: <https://code.djangoproject.com/ticket/31881#comment:3> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-updates+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/065.e11fb0afce9a2d37b44e976dfd88a06d%40djangoproject.com.