diff --git a/django/db/backends/oracle/operations.py b/django/db/backends/oracle/operations.py index ae6bd432fb..d48c8dd868 100644 --- a/django/db/backends/oracle/operations.py +++ b/django/db/backends/oracle/operations.py @@ -334,7 +334,7 @@ END; # always defaults to uppercase. # We simplify things by making Oracle identifiers always uppercase. if not name.startswith('"') and not name.endswith('"'): - name = '"%s"' % truncate_name(name.upper(), self.max_name_length()) + name = '"%s"' % truncate_name(name, self.max_name_length()) # Oracle puts the query text into a (query % args) construct, so % signs # in names need to be escaped. The '%%' will be collapsed back to '%' at # that stage so we aren't really making the name longer here. diff --git a/tests/backends/oracle/tests.py b/tests/backends/oracle/tests.py index 85d45805e0..a50f38dbe2 100644 --- a/tests/backends/oracle/tests.py +++ b/tests/backends/oracle/tests.py @@ -4,7 +4,9 @@ from django.db import DatabaseError, connection from django.db.models import BooleanField from django.test import TransactionTestCase -from ..models import Square +from ..models import ( + Square, VeryLongModelNameZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ, +) @unittest.skipUnless(connection.vendor == 'oracle', 'Oracle tests') @@ -16,6 +18,13 @@ class Tests(unittest.TestCase): quoted_name = connection.ops.quote_name(name) self.assertEqual(quoted_name % (), name) + def test_quote_name_db_table(self): + model = VeryLongModelNameZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ + db_table = model._meta.db_table.upper() + self.assertEqual(f'"{db_table}"', connection.ops.quote_name( + 'backends_verylongmodelnamezzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz', + )) + def test_dbms_session(self): """A stored procedure can be called through a cursor wrapper.""" with connection.cursor() as cursor: