﻿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
7372	queryset intersection either returns wrong result or raises KeyError depending on order (after queryset-refactor merge)	omat@…	nobody	"qs1 and qs2 are 2 combinable query sets. 

qs1 & qs2 resutls in qs2 (the larger set) where it should give the intersection, and

qs2 & qs1 raises KeyError.


And here are the details:

The query representing qs1 is:

{{{
SELECT ""notes_note"".""id"", ""notes_note"".""title"", ""notes_note"".""slug"", ""notes_note"".""note"", 
       ""notes_note"".""tags"", ""notes_note"".""location"", ""notes_note"".""user_id"", ""notes_note"".""added""
FROM ""notes_note"" , ""favorites_favorite"" 
WHERE ""favorites_favorite"".content_type_id = 22 
    AND ""favorites_favorite"".user_id = 30006 
    AND ""notes_note"".""id"" = ""favorites_favorite"".object_id
}}}


The query representing qs2 is:

{{{
SELECT ""notes_note"".""id"", ""notes_note"".""title"", ""notes_note"".""slug"", ""notes_note"".""note"", 
       ""notes_note"".""tags"", ""notes_note"".""location"", ""notes_note"".""user_id"", ""notes_note"".""added""
FROM ""notes_note"" 
WHERE NOT (""notes_note"".""title"" IS NULL)
}}}


The query representing (qs1 & qs2) is equivalent to the one of qs2, which is the larger query set.

When the order is reversed, i.e. (qs2 & qs1) results in ""KeyError: 'favorites_favorite'""

"		closed	Core (Other)	dev		duplicate	qsrf-cleanup queryset union, combine querysets		Unreviewed	0	0	0	0	0	0
