mirror of
https://github.com/django/django.git
synced 2025-08-28 14:34:27 +00:00
Refs #31720 -- Defined default output_field of BoolAnd() and BoolOr() aggregate functions.
This commit is contained in:
parent
a2e621b14e
commit
6ec5eb5d74
3 changed files with 19 additions and 5 deletions
|
@ -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``
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue