Refs #31720 -- Defined default output_field of BoolAnd() and BoolOr() aggregate functions.

This commit is contained in:
David Chorpash 2020-07-19 02:08:44 -06:00 committed by Mariusz Felisiak
parent a2e621b14e
commit 6ec5eb5d74
3 changed files with 19 additions and 5 deletions

View file

@ -82,11 +82,11 @@ General-purpose aggregation functions
published = models.BooleanField()
rank = models.IntegerField()
>>> from django.db.models import BooleanField, Q
>>> from django.db.models import Q
>>> from django.contrib.postgres.aggregates import BoolAnd
>>> Comment.objects.aggregate(booland=BoolAnd('published'))
{'booland': False}
>>> Comment.objects.aggregate(booland=BoolAnd(Q(rank__lt=100), output_field=BooleanField()))
>>> Comment.objects.aggregate(booland=BoolAnd(Q(rank__lt=100)))
{'booland': True}
``BoolOr``
@ -104,11 +104,11 @@ General-purpose aggregation functions
published = models.BooleanField()
rank = models.IntegerField()
>>> from django.db.models import BooleanField, Q
>>> from django.db.models import Q
>>> from django.contrib.postgres.aggregates import BoolOr
>>> Comment.objects.aggregate(boolor=BoolOr('published'))
{'boolor': True}
>>> Comment.objects.aggregate(boolor=BoolOr(Q(rank__gt=2), output_field=BooleanField()))
>>> Comment.objects.aggregate(boolor=BoolOr(Q(rank__gt=2)))
{'boolor': False}
``JSONBAgg``