From e8e8e207e72835cac3e36e3e26a864c59d5b490f Mon Sep 17 00:00:00 2001 From: Nick Pope Date: Tue, 22 Jun 2021 09:51:12 +0100 Subject: [PATCH] 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. --- tests/postgres_tests/test_aggregates.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/postgres_tests/test_aggregates.py b/tests/postgres_tests/test_aggregates.py index 688af585aa..d7656d8b50 100644 --- a/tests/postgres_tests/test_aggregates.py +++ b/tests/postgres_tests/test_aggregates.py @@ -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):