mirror of
				https://github.com/django/django.git
				synced 2025-10-31 09:41:08 +00:00 
			
		
		
		
	A way better fix for the count() issue in [7787].
The first attempt was brain-damaged. Let's never speak of it again. git-svn-id: http://code.djangoproject.com/svn/django/trunk@7788 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
		| @@ -218,7 +218,7 @@ class Query(object): | |||||||
|         obj.select_related = False |         obj.select_related = False | ||||||
|         obj.related_select_cols = [] |         obj.related_select_cols = [] | ||||||
|         obj.related_select_fields = [] |         obj.related_select_fields = [] | ||||||
|         if obj.distinct and len(obj.select) > 1: |         if len(obj.select) > 1: | ||||||
|             obj = self.clone(CountQuery, _query=obj, where=self.where_class(), |             obj = self.clone(CountQuery, _query=obj, where=self.where_class(), | ||||||
|                     distinct=False) |                     distinct=False) | ||||||
|             obj.select = [] |             obj.select = [] | ||||||
| @@ -1484,6 +1484,8 @@ class Query(object): | |||||||
|             if not self.select: |             if not self.select: | ||||||
|                 select = Count() |                 select = Count() | ||||||
|             else: |             else: | ||||||
|  |                 assert len(self.select) == 1, \ | ||||||
|  |                         "Cannot add count col with multiple cols in 'select': %r" % self.select | ||||||
|                 select = Count(self.select[0]) |                 select = Count(self.select[0]) | ||||||
|         else: |         else: | ||||||
|             opts = self.model._meta |             opts = self.model._meta | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user