From a2e621b14e85836362b7fc0e6b1bf7d7ff98e42b Mon Sep 17 00:00:00 2001 From: David Chorpash Date: Mon, 20 Jul 2020 10:15:53 +0200 Subject: [PATCH] Refs #31720 -- Added examples to BoolAnd() and BoolOr() documentation. --- docs/ref/contrib/postgres/aggregates.txt | 28 ++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/docs/ref/contrib/postgres/aggregates.txt b/docs/ref/contrib/postgres/aggregates.txt index b59555cb10..aad64a4db7 100644 --- a/docs/ref/contrib/postgres/aggregates.txt +++ b/docs/ref/contrib/postgres/aggregates.txt @@ -75,6 +75,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`` ---------- @@ -83,6 +97,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`` ------------