diff options
| author | Jacob Walls <jacobtylerwalls@gmail.com> | 2025-05-11 20:38:28 -0400 |
|---|---|---|
| committer | Sarah Boyce <42296566+sarahboyce@users.noreply.github.com> | 2025-08-07 14:28:44 +0200 |
| commit | de7bb7eab84dc53a7117127ad8eec44970efc509 (patch) | |
| tree | f4499232c79c87515393fcbe2f0bbe58c33cb631 | |
| parent | 0bff53b4138d8c6009e9040dbb8916a1271a68d7 (diff) | |
Refs #36210 -- Added missing limits in Subquery tests.
| -rw-r--r-- | tests/annotations/tests.py | 2 | ||||
| -rw-r--r-- | tests/composite_pk/test_filter.py | 4 | ||||
| -rw-r--r-- | tests/expressions/tests.py | 2 |
3 files changed, 4 insertions, 4 deletions
diff --git a/tests/annotations/tests.py b/tests/annotations/tests.py index 4c0ec66665..6cb59c7fe4 100644 --- a/tests/annotations/tests.py +++ b/tests/annotations/tests.py @@ -1019,7 +1019,7 @@ class NonAggregateAnnotationTestCase(TestCase): .values("publisher") .annotate(count=Count("pk")) .values("count") - ) + )[:1] publisher_books_qs = ( Publisher.objects.annotate( total_books=Count("book"), diff --git a/tests/composite_pk/test_filter.py b/tests/composite_pk/test_filter.py index ed6caf8034..902bd832ff 100644 --- a/tests/composite_pk/test_filter.py +++ b/tests/composite_pk/test_filter.py @@ -479,7 +479,7 @@ class CompositePKFilterTests(TestCase): Comment.objects.filter(text=Case(When(text="", then="text"), default="pk")) def test_outer_ref_pk(self): - subquery = Subquery(Comment.objects.filter(pk=OuterRef("pk")).values("id")) + subquery = Subquery(Comment.objects.filter(pk=OuterRef("pk")).values("id")[:1]) tests = [ ("", 5), ("__gt", 0), @@ -527,7 +527,7 @@ class CompositePKFilterTests(TestCase): ) def test_outer_ref_not_composite_pk(self): - subquery = Comment.objects.filter(pk=OuterRef("id")).values("id") + subquery = Comment.objects.filter(pk=OuterRef("id")).values("id")[:1] queryset = Comment.objects.filter(id=Subquery(subquery)) msg = "Composite field lookups only work with composite expressions." diff --git a/tests/expressions/tests.py b/tests/expressions/tests.py index ac06c212ea..228d73c568 100644 --- a/tests/expressions/tests.py +++ b/tests/expressions/tests.py @@ -745,7 +745,7 @@ class BasicExpressionsTests(TestCase): subquery_test = Company.objects.filter(pk__in=Subquery(small_companies)) self.assertCountEqual(subquery_test, [self.foobar_ltd, self.gmbh]) subquery_test2 = Company.objects.filter( - pk=Subquery(small_companies.filter(num_employees=3)) + pk=Subquery(small_companies.filter(num_employees=3)[:1]) ) self.assertCountEqual(subquery_test2, [self.foobar_ltd]) |
