#25998: SQLCompiler error when using Paginator + values(...) when query returns
no
data
-------------------------------------+-------------------------------------
Reporter: awbacker | Owner: nobody
Type: Uncategorized | Status: new
Component: Database layer | Version: 1.9
(models, ORM) | Keywords: SQLCompiler, Paginator,
Severity: Normal | values
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
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(0))
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.
--
Ticket URL: <https://code.djangoproject.com/ticket/25998>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/051.e7124f0cbb6a1f7f9c928b3b58a9882f%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.