mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Refs #31720 -- Defined default output_field of BoolAnd() and BoolOr() aggregate functions.
This commit is contained in:
committed by
Mariusz Felisiak
parent
a2e621b14e
commit
6ec5eb5d74
@@ -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'))
|
||||
|
||||
Reference in New Issue
Block a user