I'm constructing a query with an extra select subquery that also uses an order_by and it seems to generate SQL that MySQL doesn't like since it's generating a GROUP BY with missing parens.
The problem is similar to this doing this: Blog.objects.extra(select={ 'entry_count': 'SELECT COUNT(*) FROM blog_entry WHERE blog_entry.blog_id = blog_blog.id' },).annotate(Count('something_else', distinct = True).order_by ('entry_count') The resulting SQL puts the whole subquery in the GROUP BY section, but doesn't put ()'s around it so MySQL doesn't accept it. I am able to "fix" this problem by modifying BaseQuery.get_grouping() to simply insert ()'s around the extra_selects items, but perhaps I'm making a more fundamental mistake in creating the query? Thanks, yatish --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---