﻿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
18200	prefetch_related works invalid!	Artem Skoretskiy	nobody	"I found that getting '''!GenericRelation''' related objects by '''prefetch_related''' gives false result!

Example:
{{{#!python
from django.contrib.comments.models import Comment

class Media(models.Model):
    comments = generic.GenericRelation(Comment, object_id_field='object_pk')


>>> Media.objects.filter(pk=1731)[0].comments.all() # works as expected
[<Comment: admin: It is a new comment>]
>>> Media.objects.filter(pk=1731).prefetch_related('comments')[0].comments.all() # nothing found!
[]
>>> 
}}}

Thus ORM run proper SQL query:
{{{#!sql
SELECT *
FROM ""django_comments""
WHERE (""django_comments"".""object_pk"" IN ('1731') AND ""django_comments"".""content_type_id"" = 41 )
}}}

I may provide any information if needed. At the point I see no entry point to start digging."	Bug	closed	Database layer (models, ORM)	1.4	Normal	duplicate		tonn81@…	Unreviewed	0	0	0	0	0	0
