diff options
| author | nabil-rady <midorady9999@gmail.com> | 2023-02-15 13:43:51 +0200 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2023-02-15 16:52:31 +0100 |
| commit | 3b09f3555859495ca0d130712d240fb61493739e (patch) | |
| tree | 2b9a6567cbf4f94cb890680afa8e14956fefc22e /django | |
| parent | ce10686604de686e2bfb8ff8ead1c5604e0fbf0b (diff) | |
[4.2.x] Fixed #34320 -- Make sure constraints names are obtained from truncated columns names.
Backport of 6bdc3c58b65eb32fd63cd41849f00a17a36b4473 from main
Diffstat (limited to 'django')
| -rw-r--r-- | django/db/backends/base/schema.py | 8 |
1 files changed, 6 insertions, 2 deletions
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: |
