List Info

Thread: Queryset unions... Is that a bug?




Queryset unions... Is that a bug?
user name
2007-12-20 23:11:31
Hi,

I've been struggling with union-ing querysets. Here's an
example:

>>> qs1=User.objects.filter(........)
>>> qs1=User.objects.filter(........)
>>> qs1
[<User: john>]
>>> qs2
[]
>>> qs1 | qs2
[]
>>> qs1 or qs2
[<User: john>]

I thought that "|" was equivalent to a
"or", as mentioned in the doc:
http://www.djangoproject.com/do
cumentation/db-api/#complex-lookups-with-q-objects

I'm fairly new to Django, but this look like a bug to me. Is
that so?

Thanks!

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


Re: Queryset unions... Is that a bug?
country flaguser name
Australia
2007-12-20 23:24:57

On Thu, 2007-12-20 at 21:11 -0800, Julien wrote:
> Hi,
> 
> I've been struggling with union-ing querysets. Here's
an example:
> 
> >>> qs1=User.objects.filter(........)
> >>> qs1=User.objects.filter(........)
> >>> qs1
> [<User: john>]
> >>> qs2
> []
> >>> qs1 | qs2
> []
> >>> qs1 or qs2
> [<User: john>]
> 
> I thought that "|" was equivalent to a
"or", as mentioned in the doc:
> http://www.djangoproject.com/do
cumentation/db-api/#complex-lookups-with-q-objects
> 
> I'm fairly new to Django, but this look like a bug to
me. Is that so?

Yeah, it's a bug. See, for example, tickets #2080 and #2253.
They're
fixed on the queryset-refactor branch, so will be merged
into trunk when
that's done.

Regards,
Malcolm

-- 
What if there were no hypothetical questions? 
http://www.pointy-s
tick.com/blog/


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


Re: Queryset unions... Is that a bug?
user name
2007-12-20 23:33:57
Thanks for the hint!

This is not the first time that I stumble on the fact that
the
documentation is ahead of the code. And that's very
problematic
because you spend hours trying to understand why it doesn't
work as
the doc says, while it's in fact a bug in the code or a
feature that
hasn't been merged in the trunk yet...

Cheers!

Julien

On Dec 21, 4:24 pm, Malcolm Tredinnick <malc...pointy-stick.com>
wrote:
> On Thu, 2007-12-20 at 21:11 -0800, Julien wrote:
> > Hi,
>
> > I've been struggling with union-ing querysets.
Here's an example:
>
> > >>> qs1=User.objects.filter(........)
> > >>> qs1=User.objects.filter(........)
> > >>> qs1
> > [<User: john>]
> > >>> qs2
> > []
> > >>> qs1 | qs2
> > []
> > >>> qs1 or qs2
> > [<User: john>]
>
> > I thought that "|" was equivalent to a
"or", as mentioned in the doc:
> >http://www.djangoproject.com/documentati
on/db-api/#complex-lookups-wi...
>
> > I'm fairly new to Django, but this look like a bug
to me. Is that so?
>
> Yeah, it's a bug. See, for example, tickets #2080 and
#2253. They're
> fixed on the queryset-refactor branch, so will be
merged into trunk when
> that's done.
>
> Regards,
> Malcolm
>
> --
> What if there were no hypothetical questions?http://www.pointy-s
tick.com/blog/
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-usersgooglegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribegooglegroups.com
For more options, visit this group at htt
p://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Queryset unions... Is that a bug?
country flaguser name
Australia
2007-12-21 00:14:42

On Thu, 2007-12-20 at 21:33 -0800, Julien wrote:
> Thanks for the hint!
> 
> This is not the first time that I stumble on the fact
that the
> documentation is ahead of the code. And that's very
problematic
> because you spend hours trying to understand why it
doesn't work as
> the doc says, while it's in fact a bug in the code or a
feature that
> hasn't been merged in the trunk yet...

The documentation isn't in front of the code; that would be
horrendously
unfair to our users. Sometimes bugs creep in though.
Creating "or" joins
of querysets works sometimes and fails in some particular
cases. These
things get fixed when we discover them.

Malcolm

-- 
Quantum mechanics: the dreams stuff is made of. 
http://www.pointy-s
tick.com/blog/


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


[1-4]

about | contact  Other archives ( Real Estate discussion Medical topics )