summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJacob Walls <jacobtylerwalls@gmail.com>2025-08-26 08:54:34 -0400
committerJacob Walls <jacobtylerwalls@gmail.com>2025-08-29 13:45:08 -0400
commit2d453a2a683d73c64dc32286685eb40cbca7c425 (patch)
treec23c1006c44cd9010d06cf10e134fb0e5190cddd /tests
parent183fcebf88aa0762a2e28477f9b24c34341a75f4 (diff)
Refs #36152 -- Suppressed duplicate warning when using "%" in alias via values().
Diffstat (limited to 'tests')
-rw-r--r--tests/expressions/test_queryset_values.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/tests/expressions/test_queryset_values.py b/tests/expressions/test_queryset_values.py
index 47bd1358de..70e9166655 100644
--- a/tests/expressions/test_queryset_values.py
+++ b/tests/expressions/test_queryset_values.py
@@ -1,5 +1,6 @@
from django.db.models import F, Sum
from django.test import TestCase, skipUnlessDBFeature
+from django.utils.deprecation import RemovedInDjango70Warning
from .models import Company, Employee, JSONFieldModel
@@ -34,6 +35,12 @@ class ValuesExpressionsTests(TestCase):
[{"salary": 10}, {"salary": 20}, {"salary": 30}],
)
+ def test_values_expression_containing_percent_sign_deprecation_warns_once(self):
+ msg = "Using percent signs in a column alias is deprecated."
+ with self.assertWarnsMessage(RemovedInDjango70Warning, msg) as cm:
+ Company.objects.values(**{"alias%": F("id")})
+ self.assertEqual(len(cm.warnings), 1)
+
def test_values_expression_alias_sql_injection(self):
crafted_alias = """injected_name" from "expressions_company"; --"""
msg = (