Wednesday, March 27, 2013

Re: Using values_list and extra on same queryset

On Tue, Mar 26, 2013 at 8:14 PM, Larry Martell <larry.martell@gmail.com> wrote:
> On Tue, Mar 26, 2013 at 4:51 PM, Larry Martell <larry.martell@gmail.com> wrote:
>> I have some existing code that calls values_list on a queryset. I need
>> to add something using extra to this queryset. If I call extra before
>> values_list the extra stuff is gone from the query after the
>> values_list. If I call extra after the call to values_list it seems to
>> have to effect - the extra stuff is not in the query. Is there some
>> way to use both values_list and extra on same queryset?
>
> I think I may have found a bug. I stepped though the code, and
> values_list() does want to respect any extras that may have been
> added. In django/db/models/query.py(962)_setup_query() it does:
>
> if not self.query.extra and not self.query.aggregates:
>
> And for my case that is returning false, but I do have extras:
>
> (Pdb) print not self.query.extra
> False
> (Pdb) print self.query.extra
> {'top-bottom': (u'top-bottom', [])}
>
>
> This does not seem correct to me. Am I missing something here (because
> I've been coding since 4:30am and it's 8pm now)?

Ignore my last message - I was seriously sleep deprive3d when I made
it. But my original question remains - how can I use values_list and
extra on same queryset?

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment