Hi Julien,

I think the OR'ing of querysets (unions) is bogus.

When I have a queryset that has some 'extra' parameter that builds a
non-exclusive join SQL, and try to merge it with an other queryset,
the table names are not handled correctly. Sometimes some tables are
ignored and sometimes they are injected into SQL's FROM multiple times
resulting in a DB error.

I tried to explain the problem here, last week:
http://groups.google.com/group/django-users/browse_thread/thread/48cd89cd0ab099e1/

And I found a ticket that can be related to the issues:
http://code.djangoproject.com/ticket/7277

I tried to track down the problem in the django.db.query and solve my
problems partially by monkey patching but I am not comfortable at all
and looking forward for the official resolution.


--
omat



On May 30, 9:57 am, Julien <[EMAIL PROTECTED]> wrote:
> Hi,
>
> A while ago I stumbled on a bug with OR lookups, but Malcolm had
> apparently fixed it in the queryset-refactor branch [1]. However I've
> just got a similar issue. Is that still a bug or am I mis-using it?
>
> Here's my model:
>
> class Contact(models.Model):
>     requesting_user = models.ForeignKey(User,
> related_name='contacts_has_requested')
>     requested_user = models.ForeignKey(User,
> related_name='contacts_was_requested')
>     is_blocked = models.BooleanField(default=False)
>
> Now the test code:
>
>     q1 = Q(contacts_was_requested__is_blocked=False,
> contacts_was_requested__requesting_user=self)
>     p1=User.objects.filter(q1)
> => returns: QuerySet: []
>
>     q2 = Q(contacts_has_requested__is_blocked=False,
> contacts_has_requested__requested_user=self)
>     p2=User.objects.filter(q2)
> => returns: QuerySet: [<User: user_5>]
>
>     p3=User.objects.filter(q1 | q2)
> => returns: QuerySet: []
>
> Shouldn't the '|' sign do a union of the two intermediary querysets?
>
> Am I missing something?
>
> Thanks a lot,
>
> Julien
>
> [1]http://groups.google.com/group/django-users/browse_thread/thread/a467...
--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to