1
0
mirror of https://github.com/django/django.git synced 2025-10-24 22:26:08 +00:00

Fixed #34320 -- Make sure constraints names are obtained from truncated columns names.

This commit is contained in:
nabil-rady
2023-02-15 13:43:51 +02:00
committed by Mariusz Felisiak
parent 3cc7a92189
commit 6bdc3c58b6
2 changed files with 37 additions and 2 deletions

View File

@@ -11,7 +11,7 @@ from django.db.backends.ddl_references import (
Statement,
Table,
)
from django.db.backends.utils import names_digest, split_identifier
from django.db.backends.utils import names_digest, split_identifier, truncate_name
from django.db.models import Deferrable, Index
from django.db.models.sql import Query
from django.db.transaction import TransactionManagementError, atomic
@@ -1760,7 +1760,11 @@ class BaseDatabaseSchemaEditor:
"""Return all constraint names matching the columns and conditions."""
if column_names is not None:
column_names = [
self.connection.introspection.identifier_converter(name)
self.connection.introspection.identifier_converter(
truncate_name(name, self.connection.ops.max_name_length())
)
if self.connection.features.truncates_names
else self.connection.introspection.identifier_converter(name)
for name in column_names
]
with self.connection.cursor() as cursor: