﻿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
8218	extra() with params and filter() does not return results	valankar@…	nobody	"I'm seeing some strange behavior with the latest 1.0 alpha when using extra() with params and filter(). Here is an example based on the Polls app created in the tutorial.

{{{
>>> from mysite.polls.models import Poll, Choice
>>> p = Poll(question=""What's up?"", pub_date=datetime.datetime.now())
>>> p.save()
>>> polls = Poll.objects.extra(select={'blah': 'select count(*) from polls_poll where id=%s'}, params=[1])
>>> [p for p in polls]
[<Poll: Poll object>]
>>> [p.blah for p in polls]
[1]
}}}

Looks good so far, but as soon as I add a filter() to it that should return results, I get none:

{{{
>>> polls = Poll.objects.extra(select={'blah': 'select count(*) from polls_poll where id=%s'}, params=[1])
>>> polls = polls.filter(question=""What's up?"")
>>> [p for p in polls]
[]
}}}

Note that the filter by itself works fine:

{{{
>>> polls = Poll.objects.filter(question=""What's up?"")
>>> [p for p in polls]
[<Poll: Poll object>]
}}}

If I take out the extra() params it also works ok:

{{{
>>> polls = Poll.objects.extra(select={'blah': 'select count(*) from polls_poll where id=1'})
>>> polls = polls.filter(question=""What's up?"")
>>> [p for p in polls]
[<Poll: Poll object>]
>>> [p.blah for p in polls]
[1]
}}}

It's only when I combine with an extra() AND params that the problem shows up. I am using sqlite3. Thanks.
"		closed	Database layer (models, ORM)	dev		worksforme	extra filter params		Unreviewed	0	0	0	0	0	0
