1
0
mirror of https://github.com/django/django.git synced 2025-08-21 01:09:13 +00:00

Refs #36210 -- Added missing limits in Subquery tests.

This commit is contained in:
Jacob Walls 2025-05-11 20:38:28 -04:00 committed by Sarah Boyce
parent 0bff53b413
commit de7bb7eab8
3 changed files with 4 additions and 4 deletions

View File

@ -1019,7 +1019,7 @@ class NonAggregateAnnotationTestCase(TestCase):
.values("publisher") .values("publisher")
.annotate(count=Count("pk")) .annotate(count=Count("pk"))
.values("count") .values("count")
) )[:1]
publisher_books_qs = ( publisher_books_qs = (
Publisher.objects.annotate( Publisher.objects.annotate(
total_books=Count("book"), total_books=Count("book"),

View File

@ -479,7 +479,7 @@ class CompositePKFilterTests(TestCase):
Comment.objects.filter(text=Case(When(text="", then="text"), default="pk")) Comment.objects.filter(text=Case(When(text="", then="text"), default="pk"))
def test_outer_ref_pk(self): 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 = [ tests = [
("", 5), ("", 5),
("__gt", 0), ("__gt", 0),
@ -527,7 +527,7 @@ class CompositePKFilterTests(TestCase):
) )
def test_outer_ref_not_composite_pk(self): 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)) queryset = Comment.objects.filter(id=Subquery(subquery))
msg = "Composite field lookups only work with composite expressions." msg = "Composite field lookups only work with composite expressions."

View File

@ -745,7 +745,7 @@ class BasicExpressionsTests(TestCase):
subquery_test = Company.objects.filter(pk__in=Subquery(small_companies)) subquery_test = Company.objects.filter(pk__in=Subquery(small_companies))
self.assertCountEqual(subquery_test, [self.foobar_ltd, self.gmbh]) self.assertCountEqual(subquery_test, [self.foobar_ltd, self.gmbh])
subquery_test2 = Company.objects.filter( 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]) self.assertCountEqual(subquery_test2, [self.foobar_ltd])