﻿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
9899	GenericRelation of a childmodel can't be used in lookup	miracle2k	nobody	"{{{
class Feature(models.Model):
    object_id = models.PositiveIntegerField()
    content_type = models.ForeignKey(ContentType)
    content_object = GenericForeignKey()
    is_public = models.BooleanField()

class Base(models.Model):
    pass

class Child(models.Model):
    features = GenericRelation(Feature)
}}}

{{{
>>> Child.objects.filter(features__ispublic=False).count()
<class '_mysql_exceptions.OperationalError'>: (1054, ""Unknown column 'app_feature.base_ptr_id' in 'where clause'"")
}}}

The query that is executed:

{{{
SELECT COUNT(*) FROM `app_child` INNER JOIN `app_feature` ON (`app_child`.`feed_ptr_id` = `app_feature`.`object_id`) INNER JOIN `app_feature` T4 ON (`app_feature`.`feed_ptr_id` = T4.`id`) WHERE (`app_feature`.`feed_ptr_id` IS NOT NULL AND T4.`content_type_id` = %s )
}}}"		new	Database layer (models, ORM)	1.0					Unreviewed	0	0	0	0		
