Monday, January 3, 2011

Bug when OR'ing an empty Q() with a non-empty Q()?

I find that if I filter by ORing an empty Q() with a non-empty Q()
that I don't get the expected result. I would expect that this should
return all objects of the specified model that the empty Q() would
return. Let me use an example to be more clear:

I have a single Task object with its name set to foo.

Task.objects.filter(Q()) gives me that one object:
[<Task: foo>]

But:

Task.objects.filter(Q()|Q(name="bar"))

returns []

Is this a bug or am I misunderstanding something? This is on Django
1.2.1

Thanks for any pointers,

Margie

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

No comments:

Post a Comment