mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Fixed #33018 -- Fixed annotations with empty queryset.
Thanks Simon Charette for the review and implementation idea.
This commit is contained in:
committed by
Mariusz Felisiak
parent
ad36a198a1
commit
dd1fa3a31b
@@ -210,6 +210,12 @@ class NonAggregateAnnotationTestCase(TestCase):
|
||||
self.assertEqual(len(books), Book.objects.count())
|
||||
self.assertTrue(all(not book.selected for book in books))
|
||||
|
||||
def test_empty_queryset_annotation(self):
|
||||
qs = Author.objects.annotate(
|
||||
empty=Subquery(Author.objects.values('id').none())
|
||||
)
|
||||
self.assertIsNone(qs.first().empty)
|
||||
|
||||
def test_annotate_with_aggregation(self):
|
||||
books = Book.objects.annotate(is_book=Value(1), rating_count=Count('rating'))
|
||||
for book in books:
|
||||
|
||||
Reference in New Issue
Block a user