#10621: Add a way to have an aggregate() result as a queryset
---------------------------------------------------+------------------------
          Reporter:  mtredinnick                   |         Owner:  nobody
            Status:  new                           |     Milestone:  1.2   
         Component:  Database layer (models, ORM)  |       Version:        
        Resolution:                                |      Keywords:        
             Stage:  Accepted                      |     Has_patch:  0     
        Needs_docs:  0                             |   Needs_tests:  0     
Needs_better_patch:  0                             |  
---------------------------------------------------+------------------------
Comment (by tobias):

 Maybe I misunderstand the problem, but in (postgre)SQL there is no way to
 filter on an aggregate column, e.g.:

 {{{
 django_test=# SELECT "testapp_parent"."id", COUNT("testapp_child"."id") AS
 "num"
 FROM "testapp_parent"
 LEFT OUTER JOIN "testapp_child" ON ("testapp_parent"."id" =
 "testapp_child"."parent_id")
 WHERE "num" = 0
 GROUP BY "testapp_parent"."id";
 ERROR:  column "num" does not exist
 LINE 1: ...parent"."id" = "testapp_child"."parent_id") WHERE "num" = 0 ...
 }}}

 You can ORDER BY aggregate columns (so perhaps this idea is still useful)
 but I'm not sure it'll work with .filter(num=item_count)

-- 
Ticket URL: <http://code.djangoproject.com/ticket/10621#comment:2>
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 django-updates@googlegroups.com
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to