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:
parent
1aca9fc7d2
commit
e8e8e207e7
|
@ -278,8 +278,9 @@ class TestGeneralAggregate(PostgreSQLTestCase):
|
||||||
values = AggregateTestModel.objects.aggregate(jsonbagg=JSONBAgg('char_field'))
|
values = AggregateTestModel.objects.aggregate(jsonbagg=JSONBAgg('char_field'))
|
||||||
self.assertEqual(values, {'jsonbagg': ['Foo1', 'Foo2', 'Foo4', 'Foo3']})
|
self.assertEqual(values, {'jsonbagg': ['Foo1', 'Foo2', 'Foo4', 'Foo3']})
|
||||||
|
|
||||||
def test_jsonb_agg_empty(self):
|
def test_jsonb_agg_empty_result(self):
|
||||||
values = AggregateTestModel.objects.none().aggregate(jsonbagg=JSONBAgg('integer_field'))
|
AggregateTestModel.objects.all().delete()
|
||||||
|
values = AggregateTestModel.objects.aggregate(jsonbagg=JSONBAgg('integer_field'))
|
||||||
self.assertEqual(values, json.loads('{"jsonbagg": []}'))
|
self.assertEqual(values, json.loads('{"jsonbagg": []}'))
|
||||||
|
|
||||||
def test_jsonb_agg_charfield_ordering(self):
|
def test_jsonb_agg_charfield_ordering(self):
|
||||||
|
|
Loading…
Reference in New Issue