summaryrefslogtreecommitdiff
path: root/tests/backends/test_ddl_references.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/backends/test_ddl_references.py')
-rw-r--r--tests/backends/test_ddl_references.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/backends/test_ddl_references.py b/tests/backends/test_ddl_references.py
index bd4036ee33..ab3ba6ccd2 100644
--- a/tests/backends/test_ddl_references.py
+++ b/tests/backends/test_ddl_references.py
@@ -5,6 +5,7 @@ from django.db.backends.ddl_references import (
from django.db.models import ExpressionList, F
from django.db.models.functions import Upper
from django.db.models.indexes import IndexExpression
+from django.db.models.sql import Query
from django.test import SimpleTestCase, TransactionTestCase
from .models import Person
@@ -229,6 +230,27 @@ class ExpressionsTests(TransactionTestCase):
str(self.expressions),
)
+ def test_rename_table_references_without_alias(self):
+ compiler = Query(Person, alias_cols=False).get_compiler(connection=connection)
+ table = Person._meta.db_table
+ expressions = Expressions(
+ table=table,
+ expressions=ExpressionList(
+ IndexExpression(Upper('last_name')),
+ IndexExpression(F('first_name')),
+ ).resolve_expression(compiler.query),
+ compiler=compiler,
+ quote_value=self.editor.quote_value,
+ )
+ expressions.rename_table_references(table, 'other')
+ self.assertIs(expressions.references_table(table), False)
+ self.assertIs(expressions.references_table('other'), True)
+ expected_str = '(UPPER(%s)), %s' % (
+ self.editor.quote_name('last_name'),
+ self.editor.quote_name('first_name'),
+ )
+ self.assertEqual(str(expressions), expected_str)
+
def test_rename_column_references(self):
table = Person._meta.db_table
self.expressions.rename_column_references(table, 'first_name', 'other')