summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJacob Walls <jacobtylerwalls@gmail.com>2025-05-14 22:49:52 -0400
committerSarah Boyce <42296566+sarahboyce@users.noreply.github.com>2025-05-16 08:21:18 +0200
commit6228a35095d06fecf55bc1a3308ab4d46cc2d57b (patch)
treed67b07b625f8a2c7484011c5b68eb9ad1ee948e8 /tests
parent954e24758c7603ff63f7b4e8308c669bfa4e256f (diff)
[5.2.x] Fixed #36392 -- Raised ValueError when subquery referencing composite pk selects too many columns.
Backport of 994dc6d8a1bae717baa236b65e11cf91ce181c53 from main.
Diffstat (limited to 'tests')
-rw-r--r--tests/composite_pk/test_filter.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/tests/composite_pk/test_filter.py b/tests/composite_pk/test_filter.py
index 39f19daecc..c00b6660d8 100644
--- a/tests/composite_pk/test_filter.py
+++ b/tests/composite_pk/test_filter.py
@@ -206,6 +206,14 @@ class CompositePKFilterTests(TestCase):
[self.comment_1],
)
+ def test_filter_by_pk_in_subquery_invalid_selected_columns(self):
+ msg = (
+ "The QuerySet value for the 'in' lookup must have 2 selected "
+ "fields (received 3)"
+ )
+ with self.assertRaisesMessage(ValueError, msg):
+ Comment.objects.filter(pk__in=Comment.objects.values("pk", "text"))
+
def test_filter_by_pk_in_none(self):
with self.assertNumQueries(0):
self.assertSequenceEqual(