#11090: Query.group_by behaviour no longer supports MySQL specific behaviour
-----------------------------+----------------------------------------------
Reporter: miracle2k | Owner:
Status: new | Milestone:
Component: ORM aggregation | Version: SVN
Keywords: | Stage: Unreviewed
Has_patch: 0 |
-----------------------------+----------------------------------------------
I used to be able to do:
{{{
qs = Model.objects.extra(select={'foo': 'custom_aggregate()'},
tables=['table'])
qs.query.group_by = ['table.column']
}}}
This generated a query like:
{{{
SELECT model.a, model.b, custom_aggregate() AS foo FROM model, table GROUP
BY table.column
}}}
As far as I understand, this is exploiting MySQL specific behaviour that
supports collapsing multiple values within a group into a single return
row, rather than enforcing every column to be either listed in GROUP BY,
or be an aggregate, as Postgre does, for example.
Now, with the changes from r9805 and later also r9838, when using any kind
of group_by value at all, the resulting query will actually list all
select, select_related and extra_select fields in the GROUP BY clause,
meaning my query is now:
{{{
SELECT model.a, model.b, custom_aggregate() AS foo FROM model, table GROUP
BY table.column, model.a, model.b, foo
}}}
I realize that group_by is internal API and Django may not want to support
this at all, but in case the change was unintentional, I thought I'd bring
it up.
--
Ticket URL: <http://code.djangoproject.com/ticket/11090>
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
-~----------~----~----~----~------~----~------~--~---