Skip to content

Commit

Permalink
Fixed #32653 -- Made quoting names in the Oracle backend consistent w…
Browse files Browse the repository at this point in the history
…ith db_table.
  • Loading branch information
felixxm authored Apr 30, 2021
1 parent 54da6e2 commit 1f643c2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion django/db/backends/oracle/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ def quote_name(self, name):
# 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.
Expand Down
11 changes: 10 additions & 1 deletion tests/backends/oracle/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
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')
Expand All @@ -16,6 +18,13 @@ def test_quote_name(self):
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:
Expand Down

0 comments on commit 1f643c2

Please sign in to comment.