#11916: Extra params + aggregation creates incorrect SQL.
---------------------------------------------------+------------------------
          Reporter:  jaklaas...@gmail.com          |         Owner:  nobody
            Status:  reopened                      |     Milestone:        
         Component:  Database layer (models, ORM)  |       Version:  1.1   
        Resolution:                                |      Keywords:        
             Stage:  Unreviewed                    |     Has_patch:  0     
        Needs_docs:  0                             |   Needs_tests:  0     
Needs_better_patch:  0                             |  
---------------------------------------------------+------------------------
Changes (by paluh):

  * status:  closed => reopened
  * resolution:  duplicate =>

Comment:

 I think it's that this ticket is not duplicate of #11104, and it's related
 to bug in grouping columns list generation:  statements of extra selects
 are taken to column list instead of keys. my patch (which I've attached):

 {{{
 --- django/db/models/sql/query.py       (revision 11729)
 +++ django/db/models/sql/query.py       (working copy)
 @@ -885,9 +885,9 @@
              group_by = self.group_by or []

              extra_selects = []
 -            for extra_select, extra_params in
 self.extra_select.itervalues():
 -                extra_selects.append(extra_select)
 -                params.extend(extra_params)
 +            for extra_select_key in self.extra_select.iterkeys():
 +                extra_selects.append(extra_select_key)
 +
              for col in group_by + self.related_select_cols +
 extra_selects:
                  if isinstance(col, (list, tuple)):
                      result.append('%s.%s' % (qn(col[0]), qn(col[1])))


 }}}

-- 
Ticket URL: <http://code.djangoproject.com/ticket/11916#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