#24442: Index name truncation is odd
--------------------------------------+------------------------
Reporter: shaib | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: master
Severity: Normal | Keywords: oracle
Triage Stage: Accepted | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
--------------------------------------+------------------------
The code that generates index names for migrations
(https://github.com/django/django/blob/8ca35d7c6a639933927f45b439363a1614da56f1/django/db/backends/base/schema.py#L789)
behaves in undesired ways when the name it has created turns out to be too
long. It starts by cutting out parts of the table name (with no
compensation hash), which could lead to name-uniqueness violations; and in
case this wasn't enough, just gives up on meaningful naming and replaces
the whole name with a digest.
We should do better. Here's one suggestion: divide the available name
length into 3 equal parts -- one for the table name, one for the first
column name, and one for the uniqueness-digest and suffix. Make each part
fit its size by the normal truncation method, replacing its end with a
4-hexdigit hash if necessary.
I'm tempted to mark this a blocker -- so that we don't end up with
incorrectly named indexes in the wild.
--
Ticket URL: <https://code.djangoproject.com/ticket/24442>
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/048.a80ce72ac74bdf3a426c8351fa666db1%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.