summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJaeHyuck Sa <wogur981208@gmail.com>2026-01-16 00:29:25 +0900
committerJacob Walls <jacobtylerwalls@gmail.com>2026-01-16 10:28:14 -0500
commit0239e86f387127dace7273208c300b33a065e021 (patch)
treeb57524a6845b2716b4d7d6167d706d34e65a4098 /tests
parenta77e541d1d8766b0e7d2c4143076ef07973f5bd9 (diff)
Fixed #36352 -- Improved error message for fields excluded by prior values()/values_list() calls.
Signed-off-by: JaeHyuck Sa <wogur981208@gmail.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/annotations/tests.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/annotations/tests.py b/tests/annotations/tests.py
index 6336cabafa..69a2b4a7c7 100644
--- a/tests/annotations/tests.py
+++ b/tests/annotations/tests.py
@@ -482,6 +482,17 @@ class NonAggregateAnnotationTestCase(TestCase):
with self.assertRaisesMessage(FieldError, expected_message % article_fields):
Book.objects.annotate(annotation=Value(1)).values_list("annotation_typo")
+ def test_chained_values_masked_annotation_error_message(self):
+ msg = (
+ "Cannot select the 'author_id' alias. It was excluded by a "
+ "previous values() or values_list() call. Include 'author_id' in "
+ "that call to select it."
+ )
+ with self.assertRaisesMessage(FieldError, msg):
+ Book.objects.annotate(
+ author_name=F("authors__name"), author_id=F("authors__id")
+ ).values("author_name").values("author_id")
+
def test_decimal_annotation(self):
salary = Decimal(10) ** -Employee._meta.get_field("salary").decimal_places
Employee.objects.create(