diff options
author | David Wobrock <david.wobrock@gmail.com> | 2021-08-31 22:37:07 +0200 |
---|---|---|
committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2021-09-01 20:59:16 +0200 |
commit | 691486a5cf7588c95250a873c5b57748e82fc4c2 (patch) | |
tree | 43075274e06f95450f3ab361279c61a0d0a40996 /tests/aggregation | |
parent | 338fc0e7f10f7ca781b059f2ff46e1a1a85c91f8 (diff) | |
download | django-691486a5cf7588c95250a873c5b57748e82fc4c2.tar.gz |
Fixed #33073 -- Fixed queryset crash with aggregation and empty/extra queryset annotation.
Diffstat (limited to 'tests/aggregation')
-rw-r--r-- | tests/aggregation/tests.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/aggregation/tests.py b/tests/aggregation/tests.py index c5fd590543..85742dcb9c 100644 --- a/tests/aggregation/tests.py +++ b/tests/aggregation/tests.py @@ -1603,3 +1603,17 @@ class AggregateTestCase(TestCase): value=Sum('price', filter=Q(rating__lt=3.0), default=Avg('pages') / 10.0), ) self.assertAlmostEqual(result['value'], Decimal('61.72'), places=2) + + def test_exists_none_with_aggregate(self): + qs = Book.objects.all().annotate( + count=Count('id'), + exists=Exists(Author.objects.none()), + ) + self.assertEqual(len(qs), 6) + + def test_exists_extra_where_with_aggregate(self): + qs = Book.objects.all().annotate( + count=Count('id'), + exists=Exists(Author.objects.extra(where=['1=0'])), + ) + self.assertEqual(len(qs), 6) |