diff options
author | David Wobrock <david.wobrock@gmail.com> | 2021-09-29 00:00:50 +0200 |
---|---|---|
committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2021-09-29 20:23:29 +0200 |
commit | dd1fa3a31b4680c0d3712e6ae122b878138580c7 (patch) | |
tree | 10205352e74cd3708581c7c262d25840be6aa12a /tests/annotations | |
parent | ad36a198a12df4dff65992191b3eb0a474e2daac (diff) | |
download | django-dd1fa3a31b4680c0d3712e6ae122b878138580c7.tar.gz |
Fixed #33018 -- Fixed annotations with empty queryset.
Thanks Simon Charette for the review and implementation idea.
Diffstat (limited to 'tests/annotations')
-rw-r--r-- | tests/annotations/tests.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/tests/annotations/tests.py b/tests/annotations/tests.py index c0fe308a07..62912ee99c 100644 --- a/tests/annotations/tests.py +++ b/tests/annotations/tests.py @@ -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: |