From 6bdc3c58b65eb32fd63cd41849f00a17a36b4473 Mon Sep 17 00:00:00 2001 From: nabil-rady Date: Wed, 15 Feb 2023 13:43:51 +0200 Subject: Fixed #34320 -- Make sure constraints names are obtained from truncated columns names. --- django/db/backends/base/schema.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'django') diff --git a/django/db/backends/base/schema.py b/django/db/backends/base/schema.py index 3a83e14be9..070211f6d2 100644 --- a/django/db/backends/base/schema.py +++ b/django/db/backends/base/schema.py @@ -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: -- cgit v1.3