Ensured that empty result test for JSONBAgg executes a query.

Use of QuerySet.none() will cause the EmptyQuerySet aggregation
optimisation to be used. Change the test to be implemented like the
other tests for empty results in this file.
This commit is contained in:
Nick Pope 2021-06-22 09:51:12 +01:00 committed by Mariusz Felisiak
parent 1aca9fc7d2
commit e8e8e207e7
1 changed files with 3 additions and 2 deletions

View File

@ -278,8 +278,9 @@ class TestGeneralAggregate(PostgreSQLTestCase):
values = AggregateTestModel.objects.aggregate(jsonbagg=JSONBAgg('char_field'))
self.assertEqual(values, {'jsonbagg': ['Foo1', 'Foo2', 'Foo4', 'Foo3']})
def test_jsonb_agg_empty(self):
values = AggregateTestModel.objects.none().aggregate(jsonbagg=JSONBAgg('integer_field'))
def test_jsonb_agg_empty_result(self):
AggregateTestModel.objects.all().delete()
values = AggregateTestModel.objects.aggregate(jsonbagg=JSONBAgg('integer_field'))
self.assertEqual(values, json.loads('{"jsonbagg": []}'))
def test_jsonb_agg_charfield_ordering(self):