First let me mention I am on sqlite3! Perhaps it doesn't support this? I do not know much about the various sql db interfaces, so I have no idea what supports what ..
I've actually sort of lost track at this point of what I was originally trying to do. But here's some more information on the general issue, with the output from as_sql() for the case that seems to not work. Let me know if you still think it is a bug and I will post it. >>> Tile.objects.all() [<Tile: ll_1>, <Tile: ll_2>, <Tile: ll_3>, <Tile: ll_4>] # When I filter based on Tile.objects.all()[0] I get an error - it's not interable. This seems reasonable >>> PdTask.objects.filter(tiles__in=Tile.objects.all()[0]) TypeError: 'Tile' object is not iterable # So instead I'll put the rhs of tiles_in into a list to find all PdTask objects that have tile 'll_1' in their tiles m2m field # This returns two tasks (the first named 'foo', the second happens to have no name) >>> PdTask.objects.filter(tiles__in=[Tile.objects.all()[0]]) [<PdTask: foo>, <PdTask: >] # Now do the same thing using the slice Tile.objects.all()[0:1]. I think this should return the same two pdtasks, but it returns empty list [<PdTask: foo>, <PdTask: >] >>> PdTask.objects.filter(tiles__in=Tile.objects.all()[0:1]) [] # Here's the sql query generated for the above example: >>> PdTask.objects.filter(tiles__in=Tile.objects.all()[0:1]).query.as_sql() ('SELECT "pdtaskmanager_pdtask"."id", "pdtaskmanager_pdtask"."created", "pdtaskmanager_pdtask"."modified", "pdtaskmanager_pdtask"."name", "pdtaskmanager_pdtask"."deadline", "pdtaskmanager_pdtask"."priority", "pdtaskmanager_pdtask"."description", "pdtaskmanager_pdtask"."owner_id", "pdtaskmanager_pdtask"."status", "pdtaskmanager_pdtask"."result", "pdtaskmanager_pdtask"."forum_id", "pdtaskmanager_pdtask"."parentTask_id", "pdtaskmanager_pdtask"."chip_id", "pdtaskmanager_pdtask"."stage_id" FROM "pdtaskmanager_pdtask" INNER JOIN "pdtaskmanager_pdtask_tiles" ON ("pdtaskmanager_pdtask"."id" = "pdtaskmanager_pdtask_tiles"."pdtask_id") WHERE "pdtaskmanager_pdtask_tiles"."tile_id" IN (SELECT U0."id" FROM "chipmanager_tile" U0 LIMIT 1) ORDER BY "pdtaskmanager_pdtask"."deadline" DESC', ()) Margie On Apr 16, 12:15 am, Malcolm Tredinnick <malc...@pointy-stick.com> wrote: > On Thu, 2009-04-16 at 00:01 -0700, Margie wrote: > > Ah - ok, cool, good to know. I am on 1.1 pre-alpha SVN-9814. > > Hmm .. then maybe there's an actual problem there. The ability to use > nested querysets was added in r9701 (with a few bug fixes in subsequent > patches). I only said 1.1-beta as a rough reference point, as opposed to > 1.0.X. > > Might be worth having a look at the SQL that is being generated to see > what's going on there. Maybe I've screwed up limits or something (I > can't really stop to test this myself right now, as I'm still at work). > > Have a look at the output of > > PdTask.objects.filter(tiles__in=pdTask.objects.all()[0]).query.as_sql() > > and see if it looks broken in any obvious fashion. If so, feel free to > open a ticket (assign it to "mtredinnick" so I'll remember to look at it > on the weekend). You shoudl still try a slightly later version > (something around beta-1) just to check it wasn't fixed by some of the > later tweaks in that area, but I'm now a bit suspicious that something > is going wrong. > > Regards, > Malcolm --~--~---------~--~----~------------~-------~--~----~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---