﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
10916	annotate() method doesn't include content_type_id into WHERE clause when used with generic relations	skam		"Content type must be included to WHERE clause to prevent object_id's collisions.

{{{
>>> qs = Car.objects.annotate(gallery__count=Count('galleries')).order_by('-gallery__count')
>>> qs.query.as_sql()
('SELECT `cars_car`.`id`, `cars_car`.`brand_id`, `cars_car`.`name`, `cars_car`.`year`, `cars_car`.`slug`, 
 `cars_car`.`image`, `cars_car`.`description`, COUNT(`gallery_gallery`.`id`) AS `gallery__count` 
 FROM `cars_car` LEFT OUTER JOIN `gallery_gallery` ON (`cars_car`.`id` = `gallery_gallery`.`object_id`) 
 GROUP BY `cars_car`.`id` ORDER BY gallery__count DESC', ())

}}}
"		closed	Database layer (models, ORM)	dev		duplicate			Unreviewed	0	0	0	0	0	0
