On Wed, 2014-08-13 at 04:38 +0300, Shai Berger wrote:
> On Friday 08 August 2014 10:41:20 Anssi Kääriäinen wrote:
> > 
> > As for addition of .exists lookup - how
> > should .filter(somefield__exists=False, somefield__othercol=2) work?
> 
> It should be noted that __exists is a little special. For the False case 
> above,
> 
> .filter(somefield__exists=False, somefield__othercol=2)
> 
> should always get an empty result set, and for the True case, 
> somefield__othercol=2 already implies somefield__exists=True. So while it 
> would 
> be really nice to have sane behavior there, it is not much of a real problem 
> in practice.

Hmmh, my interpretation was that the above filter would check if there
exists any somefield relations with othercol value=2. But that
interpretation is wrong.

But, how about .filter(Q(somefield__exists=False) |
Q(somefield__othercol=2))? This one should return results only if there
are no somefield related instances at all, or if there are related
instances, then at least one of those instances must have othercol
value=2. So, both filters must target the same join (if my
interpretation is correct...).

 - Anssi


-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" 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].
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/1407912933.11410.176.camel%40TTY32.
For more options, visit https://groups.google.com/d/optout.

Reply via email to