﻿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
7526	Query Set Refactor handling of INNER JOINs	khoobks	George Vilches	"Hi,

The best way for me to explain the issue I have discovered is to run the test case provided with this ticket. The test case is a modification of the many_to_one test case that comes with Django. I have commented out the ""unnecessary"" bits for clarity.

The problem that I am reporting is that due to the way that the ordering is expressed in the example, a join to the related table is necessary. 
When performing any query on this model (except a count) an INNER JOIN is used in the SQL command. If we are trying to get all rows (from a table that contains some rows) using ""all()"", an INNER JOIN will be performed to the related table which, in the example contains no rows. This results in the ""all()"" function returning an empty query set which is incorrect. I think.

Regards

"		closed	Database layer (models, ORM)	dev		duplicate	query set refactor order_by inner join		Unreviewed	0	0	0	0	0	0
