diff options
| author | David Chorpash <davidchorpash@gmail.com> | 2020-07-19 02:08:44 -0600 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2020-07-21 06:42:51 +0200 |
| commit | 6ec5eb5d74fd18a91256010706ab8b5b583526a9 (patch) | |
| tree | d233e66945939725ab3bbd1a4fa0b6d28182d37d /tests/postgres_tests | |
| parent | a2e621b14e85836362b7fc0e6b1bf7d7ff98e42b (diff) | |
Refs #31720 -- Defined default output_field of BoolAnd() and BoolOr() aggregate functions.
Diffstat (limited to 'tests/postgres_tests')
| -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 8f3d8bb6ef..19f9596576 100644 --- a/tests/postgres_tests/test_aggregates.py +++ b/tests/postgres_tests/test_aggregates.py @@ -155,6 +155,12 @@ class TestGeneralAggregate(PostgreSQLTestCase): values = AggregateTestModel.objects.aggregate(booland=BoolAnd('boolean_field')) self.assertEqual(values, {'booland': None}) + def test_bool_and_q_object(self): + values = AggregateTestModel.objects.aggregate( + booland=BoolAnd(Q(integer_field__gt=2)), + ) + self.assertEqual(values, {'booland': False}) + def test_bool_or_general(self): values = AggregateTestModel.objects.aggregate(boolor=BoolOr('boolean_field')) self.assertEqual(values, {'boolor': True}) @@ -164,6 +170,12 @@ class TestGeneralAggregate(PostgreSQLTestCase): values = AggregateTestModel.objects.aggregate(boolor=BoolOr('boolean_field')) self.assertEqual(values, {'boolor': None}) + def test_bool_or_q_object(self): + values = AggregateTestModel.objects.aggregate( + boolor=BoolOr(Q(integer_field__gt=2)), + ) + self.assertEqual(values, {'boolor': False}) + def test_string_agg_requires_delimiter(self): with self.assertRaises(TypeError): AggregateTestModel.objects.aggregate(stringagg=StringAgg('char_field')) |
