﻿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
25998	SQLCompiler error when using Paginator + values(...) when query returns no data	Andrew	nobody	"I am experiencing a crash in the `SQLCompiler` when I try to execute a paginated query after calling `.values(...)`.  

{{{
AttributeError: 'SQLCompiler' object has no attribute 'col_count'
}}}

* Postgres 9.3, psycopg2==2.6.1
* Django 1.9
* No data is present in the table

{{{
# Query must have NO data returned for it
qs = Room.objects.values('id')
pg = Paginator(per_page=1, object_list=qs)
res = list(pg.page(1))

class Room(models.Model):
    has_tv = models.BooleanField()
}}}

{{{
======================================================================
ERROR: test_pure_django (api.tests.test_api_call.TestApiCall)
----------------------------------------------------------------------
Traceback (most recent call last):
  File ""/Users/andrew/dev/st/abc/api/tests/test_api_call.py"", line 25, in test_pure_django
    res = list(pg.page(1))
  File ""/Users/andrew/dev/st/abc/venv/bin/../lib/python2.7/_abcoll.py"", line 602, in __iter__
    v = self[i]
  File ""/Users/andrew/dev/st/abc/venv/lib/python2.7/site-packages/django/core/paginator.py"", line 125, in __getitem__
    self.object_list = list(self.object_list)
  File ""/Users/andrew/dev/st/abc/venv/lib/python2.7/site-packages/django/db/models/query.py"", line 258, in __iter__
    self._fetch_all()
  File ""/Users/andrew/dev/st/abc/venv/lib/python2.7/site-packages/django/db/models/query.py"", line 1074, in _fetch_all
    self._result_cache = list(self.iterator())
  File ""/Users/andrew/dev/st/abc/venv/lib/python2.7/site-packages/django/db/models/query.py"", line 112, in __iter__
    for row in compiler.results_iter():
  File ""/Users/andrew/dev/st/abc/venv/lib/python2.7/site-packages/django/db/models/sql/compiler.py"", line 807, in results_iter
    fields = [s[0] for s in self.select[0:self.col_count]]
AttributeError: 'SQLCompiler' object has no attribute 'col_count'
}}}

I have a fairly minimal reproduction, and can try to reduce it even further (removing DRF, psycopg2, etc) if needed.  I don't think it's an issue with postgres.  I think it has something to do with the ValuesIterable, but have no way of telling for sure."	Bug	closed	Database layer (models, ORM)	1.9	Normal	duplicate	SQLCompiler, Paginator, values		Unreviewed	0	0	0	0	0	0
