#28949: Multibyte table name or column name causes miscalculation of the length
of
index name.
-------------------------------------+-------------------------------------
Reporter: Pak Youngrok | Owner: Abhishek
| Gautam
Type: Bug | Status: assigned
Component: Migrations | Version: 2.0
Severity: Normal | Resolution:
Keywords: migration multibyte | Triage Stage: Accepted
index |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Abhishek Gautam):
As we just need a unique name for an index can so, can we create
index_name as :
{{{#!python
index_name = '%s%s' % (self._digest(*([table_name] + column_names)),
suffix)
}}}
_digest function will be:
{{{#!python
@classmethod
def _digest(cls, *args):
"""
Generate a 32-bit digest of a set of arguments that can be used to
shorten identifying names.
"""
h = hashlib.md5()
for arg in args:
h.update(force_bytes(arg))
return h.hexdigest()
}}}
Using _digest method we will get 32 byte string and in that we will add
suffix which will give us a length of index_name = 32 + length of suffix.
As suffix length will be very small length of index_name will not be able
to exceed 40 also.
--
Ticket URL: <https://code.djangoproject.com/ticket/28949#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 [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/066.0fc4696c0c9a1878e505d9dcbad4ce19%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.