diff options
| author | Sergey Fedoseev <fedoseev.sergey@gmail.com> | 2017-12-31 00:46:52 +0500 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2017-12-30 14:46:52 -0500 |
| commit | 149061103829fb3ad74d050b4ae3cc815b2f451c (patch) | |
| tree | fa618659ea070a57c0e46984af3849e851b3c746 /tests/postgres_tests/test_aggregates.py | |
| parent | 58ec55b157b3c4cc9dc0a944804f8a719ff4e12f (diff) | |
Fixed #28908 -- Allowed ArrayField lookups on ArrayAgg annotations.
Diffstat (limited to 'tests/postgres_tests/test_aggregates.py')
| -rw-r--r-- | tests/postgres_tests/test_aggregates.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/postgres_tests/test_aggregates.py b/tests/postgres_tests/test_aggregates.py index 056d08441b..d4a01ff027 100644 --- a/tests/postgres_tests/test_aggregates.py +++ b/tests/postgres_tests/test_aggregates.py @@ -46,6 +46,18 @@ class TestGeneralAggregate(PostgreSQLTestCase): values = AggregateTestModel.objects.aggregate(arrayagg=ArrayAgg('boolean_field')) self.assertEqual(values, {'arrayagg': []}) + def test_array_agg_lookups(self): + aggr1 = AggregateTestModel.objects.create() + aggr2 = AggregateTestModel.objects.create() + StatTestModel.objects.create(related_field=aggr1, int1=1, int2=0) + StatTestModel.objects.create(related_field=aggr1, int1=2, int2=0) + StatTestModel.objects.create(related_field=aggr2, int1=3, int2=0) + StatTestModel.objects.create(related_field=aggr2, int1=4, int2=0) + qs = StatTestModel.objects.values('related_field').annotate( + array=ArrayAgg('int1') + ).filter(array__overlap=[2]).values_list('array', flat=True) + self.assertCountEqual(qs.get(), [1, 2]) + def test_bit_and_general(self): values = AggregateTestModel.objects.filter( integer_field__in=[0, 1]).aggregate(bitand=BitAnd('integer_field')) |
