﻿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
3141	can't use count() on querysets when extra() has been used with params.	mrmachine <real dot human at mrmachine dot net>	deepak	"there seems to be a bug in django/db/models/query.py when using extra() with params on a queryset. the queryset is generated correctly, i can access it, iterate through it, but i can't count() it.

{{{
#!python
>>> from django.contrib.auth.models import User
>>> u = User.objects.filter(pk=1).extra(select={'foo': '%s'}, params=['1'])
>>> u[0].foo
'1'
>>> u.count()
Traceback (most recent call last):
  File ""<console>"", line 1, in ?
  File ""/Volumes/Singularity/Projects/django/django/db/models/query.py"", line 202, in count
    cursor.execute(""SELECT COUNT(*)"" + sql, params)
  File ""/Volumes/Singularity/Projects/django/django/db/backends/util.py"", line 19, in execute
    self.db.queries.append({
TypeError: not all arguments converted during string formatting
>>> u = User.objects.filter(pk=1).extra(select={'foo': '1'})
>>> u[0].foo
'1'
>>> u.count()
1
}}}
"	defect	closed	Database layer (models, ORM)	dev	normal	fixed	queryset extra params count, qs-rf-fixed	simon@… real.human@… heckj@…	Accepted	1	0	1	0	0	0
