Ah, glad to know that it is a known issue at least and not a new
problem. Thanks for the info.

On Oct 29, 9:07 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Mon, 2007-10-29 at 20:58 +0000, Kevin wrote:
> > I'm trying to figure out how to chain filters for a many-to-many
> > relation ship that is evaluating to an empty set when it should not. I
> > basically have some a test with multiple dimms. I want to find a test
> > with both dimm "sizes" 1024 & 2048.
>
> > class TestLine(models.Model):
> >       #...some test info
>
> > class Dimm(models.Model):
> >     testline = models.ForeignKey(TestLine)
> >     size = models.IntegerField()
>
> > models.TestLine.objects.filter(dimm__size=1024).filter(dimm__size=2048)
>
> > This returns an empty set, but I know there is a test with multiple
> > dimm objects and meets this criteria. Is there a limitation that I'm
> > missing here? Is there an alternative method to accomplish the intent
> > here?
>
> So I see you've found an alternative approach that works for now. The
> underlying thing going on here is that there is a bug in the way Django
> generates the SQL for many-to-many relations. If you try to filter on on
> the same column more than once, it still only makes a single join to the
> intermediary table, so you end up with things look like:
>
>         ... where foo_id = 6 and foo_id = 7 ...
>
> which is clearly impossible to satisfy for a unique column on the same
> table.
>
> This is ticket #1801 and has been fixed as part of the queryset-refactor
> branch. When that work is complete, it'll be merged into trunk (the
> branch is not suitable for testing yet)
>
> Regards,
> Malcolm
>
> --
> Remember that you are unique. Just like everyone 
> else.http://www.pointy-stick.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 [email protected]
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