﻿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
30047	Documentation: add a Note about default ordering on models used in Subquery filters	powderflask	nobody	"A Subquery filter on models.Obj, e.g., {{{filter(obj__in=Subquery(...))}}} ,requires that the subquery return exactly one column populated with  Obj.pk.
Documentation suggests using {{{objects.values('pk')}}}

However, if the models.Obj.Meta.ordering is set, then those ordering fields are included with the subquery results, raising the exception:

{{{
django.db.utils.ProgrammingError: subquery has too many columns
}}}

This is expected behavior, but confusing and not directly obvious in the code.  Could be more clearly documented at:
https://docs.djangoproject.com/en/dev/ref/models/expressions/#limiting-a-subquery-to-a-single-column
with a Note reading something similar to:
""""""
To avoid unintended columns being added to the subquery expression, be sure there is no order_by clause on the subquery.  In particular, watch for default ordering specified on the subquery model Meta.
"""""""	Cleanup/optimization	closed	Documentation	2.1	Normal	worksforme			Unreviewed	0	0	0	0	0	0
