#10100: "exclude" by annotation works like "filter"
-----------------------------+----------------------------------------------
Reporter: Anossov | Owner:
Status: new | Milestone:
Component: ORM aggregation | Version: SVN
Keywords: | Stage: Unreviewed
Has_patch: 0 |
-----------------------------+----------------------------------------------
"Exclude" by annotation does not negate lookup parameters:
{{{
>>> [g.num for g in
Group.objects.annotate(num=Count('sites')).exclude(num=73)]
[73]
>>> [g.num for g in
Group.objects.annotate(num=Count('sites')).filter(num=73)]
[73]
>>> e =
Group.objects.annotate(num=Count('sites')).exclude(num=73).query.as_sql()
>>> f =
Group.objects.annotate(num=Count('sites')).filter(num=73).query.as_sql()
>>> e == f
True
>>>
Group.objects.annotate(num=Count('sites')).exclude(num=73).query.as_sql()
(u'SELECT (...), COUNT(`sites`.`id`) AS `num` FROM `site_groups` LEFT
OUTER JOIN `sites` ON (`site_groups`.`id` = `sites`.`group_id`) GROUP BY
site_groups.id HAVING COUNT(`urls`.`id`) = %s ORDER BY NULL', (73,))
}}}
--
Ticket URL: <http://code.djangoproject.com/ticket/10100>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---