﻿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
14011	"QuerySet.none().values('x').query causes ""DatabaseError: subquery has too many columns"" when used in filters."	skatei <satoru.katei@…>		"Just came across this error.

{{{
class Test(models.Model):
  name = models.CharField(max_length=20)

test = Test(name='bob')
test.save()
pks = Test.objects.none().values('pk').query
print Test.objects.exclude(pk__in=pks)

DatabaseError: subquery has too many columns
}}}

The query:

{{{
SELECT
  ""error_test"".""id"",
  ""error_test"".""name"",
FROM
  ""error_test""
WHERE
  NOT (
    ""error_test"".""id""
      IN (
        SELECT
          ""error_test"".""id"",
          ""error_test"".""name"",
        FROM
          ""error_test""
      )
  )
}}}

Fixes?: 

* Substitute with {{{.filter(pk__in=[])}}} (possibly overriding none).

* Catch and deal with the exception.

* Don't let this happen in the code.

This should at least raise a more meaningful exception if deemed incorrect.

Reason i'd like it to work is because I apply filters dynamically, using some complex logic that sometimes applies a none filter.

"		closed	Database layer (models, ORM)	1.2		fixed	none query DatabaseError		Accepted	0	0	0	0	0	0
