mirror of
				https://github.com/django/django.git
				synced 2025-10-31 09:41:08 +00:00 
			
		
		
		
	[3.1.x] Refs #31720 -- Added examples to BoolAnd() and BoolOr() documentation.
Backport of a2e621b14e from master
			
			
This commit is contained in:
		
				
					committed by
					
						 Mariusz Felisiak
						Mariusz Felisiak
					
				
			
			
				
	
			
			
			
						parent
						
							f91ba43ebf
						
					
				
				
					commit
					5360f002f8
				
			| @@ -75,6 +75,20 @@ General-purpose aggregation functions | |||||||
|     Returns ``True``, if all input values are true, ``None`` if all values are |     Returns ``True``, if all input values are true, ``None`` if all values are | ||||||
|     null or if there are no values, otherwise ``False`` . |     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`` | ``BoolOr`` | ||||||
| ---------- | ---------- | ||||||
|  |  | ||||||
| @@ -83,6 +97,20 @@ General-purpose aggregation functions | |||||||
|     Returns ``True`` if at least one input value is true, ``None`` if all |     Returns ``True`` if at least one input value is true, ``None`` if all | ||||||
|     values are null or if there are no values, otherwise ``False``. |     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`` | ``JSONBAgg`` | ||||||
| ------------ | ------------ | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user