﻿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
6761	select_related broken with model inheritance	Dan Watson	nobody	"When using `select_related()` on an inherited model, it tries (and fails, obviously) to select parent fields on the child table. For instance, using the models from #6706, calling `Employer.objects.select_related()` yields the following SQL:

{{{
SELECT ""testapp_employer"".""id"", ""testapp_employer"".""first_name"", ""testapp_employer"".""last_name"",
""testapp_employer"".""personinfo_ptr_id"", ""testapp_employer"".""title"", ""testapp_employer"".""office_id"",
""testapp_personinfo"".""id"", ""testapp_personinfo"".""first_name"", ""testapp_personinfo"".""last_name"",
""testapp_location"".""id"", ""testapp_location"".""name"" FROM ""testapp_employer""
INNER JOIN ""testapp_personinfo"" ON (""testapp_employer"".""personinfo_ptr_id"" = ""testapp_personinfo"".""id"")
INNER JOIN ""testapp_location"" ON (""testapp_employer"".""office_id"" = ""testapp_location"".""id"")
ORDER BY ""testapp_personinfo"".""last_name"" ASC, ""testapp_personinfo"".""first_name"" ASC
}}}

I think the solution may involve using `opts.local_fields` in `django.db.models.sql.query.fill_related_selections`, but I don't know the code well enough to be certain."		closed	Database layer (models, ORM)	queryset-refactor		fixed	qs-rf model inheritance select_related		Unreviewed	0	0	0	0	0	0
