mirror of
https://github.com/django/django.git
synced 2025-10-26 07:06:08 +00:00
Fixed #21497 -- Forced conversion to bytes for very long index names
This commit is contained in:
@@ -5,6 +5,7 @@ from django.db.backends.creation import BaseDatabaseCreation
|
||||
from django.db.backends.utils import truncate_name
|
||||
from django.db.models.fields.related import ManyToManyField
|
||||
from django.db.transaction import atomic
|
||||
from django.utils.encoding import force_bytes
|
||||
from django.utils.log import getLogger
|
||||
from django.utils.six.moves import reduce
|
||||
from django.utils.six import callable
|
||||
@@ -703,7 +704,7 @@ class BaseDatabaseSchemaEditor(object):
|
||||
index_name = index_name[1:]
|
||||
# If it's STILL too long, just hash it down
|
||||
if len(index_name) > self.connection.features.max_index_name_length:
|
||||
index_name = hashlib.md5(index_name).hexdigest()[:self.connection.features.max_index_name_length]
|
||||
index_name = hashlib.md5(force_bytes(index_name)).hexdigest()[:self.connection.features.max_index_name_length]
|
||||
# It can't start with a number on Oracle, so prepend D if we need to
|
||||
if index_name[0].isdigit():
|
||||
index_name = "D%s" % index_name[:-1]
|
||||
|
||||
Reference in New Issue
Block a user