mirror of
https://github.com/django/django.git
synced 2025-11-25 05:04:26 +00:00
Fixed #33018 -- Fixed annotations with empty queryset.
Thanks Simon Charette for the review and implementation idea.
This commit is contained in:
parent
ad36a198a1
commit
dd1fa3a31b
5 changed files with 33 additions and 4 deletions
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue