diff options
| author | David Chorpash <davidchorpash@gmail.com> | 2020-07-20 10:15:53 +0200 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2020-07-21 07:02:29 +0200 |
| commit | 0a3c1272f2213ccd2b36081c8d587b3f33237a5d (patch) | |
| tree | 9cdadd0c3eb17a9233222a7418a696abd0988096 | |
| parent | bcb511f9d8e0fc2cee9715e839df6ca05f42aab9 (diff) | |
[3.0.x] Refs #31720 -- Added examples to BoolAnd() and BoolOr() documentation.
Backport of a2e621b14e85836362b7fc0e6b1bf7d7ff98e42b from master
| -rw-r--r-- | docs/ref/contrib/postgres/aggregates.txt | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/docs/ref/contrib/postgres/aggregates.txt b/docs/ref/contrib/postgres/aggregates.txt index c70b6ec3b3..46d56d7777 100644 --- a/docs/ref/contrib/postgres/aggregates.txt +++ b/docs/ref/contrib/postgres/aggregates.txt @@ -77,6 +77,20 @@ General-purpose aggregation functions Returns ``True``, if all input values are true, ``None`` if all values are null or if there are no values, otherwise ``False`` . + Usage example:: + + class Comment(models.Model): + body = models.TextField() + published = models.BooleanField() + rank = models.IntegerField() + + >>> from django.db.models import BooleanField, 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())) + {'booland': True} + ``BoolOr`` ---------- @@ -85,6 +99,20 @@ General-purpose aggregation functions Returns ``True`` if at least one input value is true, ``None`` if all values are null or if there are no values, otherwise ``False``. + Usage example:: + + class Comment(models.Model): + body = models.TextField() + published = models.BooleanField() + rank = models.IntegerField() + + >>> from django.db.models import BooleanField, 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())) + {'boolor': False} + ``JSONBAgg`` ------------ |
