Tuesday, July 30, 2013

Re: .filter() and .exclude() don't add up

On Mon, Jul 29, 2013, akaariai <akaariai@gmail.com> wrote:

>> I understood that part. But by "more general" I mean one that will work
>> for any case, without having to know where the Nulls might be.
>>
>> So given queryset A, and its subset queryset B, we can place B against A
>> and obtain its complement.
>>
>> Or to put it another way: give me all the items in A that are not in B.
>>
>
>You can do this with a subquery in Django. non_red_things =
>queryset.exclude(pk__in=red_things). If this performs well is a different
>thing.

It seems to take about twice as long to execute, so no, it doesn't perform very well.

>I think that in SQL one can use WHERE (original_condition) is not true;
>which will match both unknown (null comparison's result) and false in the
>original condition.

But this isn't available as a Django query, without using raw SQL?

Daniele

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment