QuerySet method count() on models with a manytomanyfield not working in the latest trunk
|Reported by:||shilin||Owned by:||nobody|
|Component:||Database layer (models, ORM)||Version:||master|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
I have a model like this:
class Thread(models.Model): group = models.ForeignKey(Group) creator = models.ForeignKey(Profile) categories = models.ManyToManyField('object.Category')
you can see that it has a manytomanyfield to the model Category in the application named object
due to the way that I'm not directly importing the model Category but use a string instead,
the following query will return a error
Thread.objects.filter(categories__in = category_list).count()
no such column: group_thread_categories.object.category_id
as in the database level, the ORM generates a query like this
'SELECT COUNT(*) FROM "group_thread" INNER JOIN "group_thread_categories" WHERE ("group_thread_categories"."object.category_id" IN (?))'
this bug doesn't appear in revision 9800 because i just checked out svn today and my code starts to break.