Below is the SQL the query, User.objects.filter(y|z).distinct().count(), generates.
It seems to do the correct OR for the where clauses, and yet still uses an INNER JOIN when that type of join is inappropriate for this particular query. Is this a known problem? Did I write the queries incorrectly? -Mike SELECT COUNT(DISTINCT("auth_user"."id")) FROM "auth_user" INNER JOIN "program_registrationprofile" AS "auth_user__registrationprofile" ON "auth_user"."id" = "auth_user__registrationprofile"."user_id" INNER JOIN "program_satprepreginfo" AS "auth_user__satprepreginfo" ON "auth_user"."id" = "auth_user__satprepreginfo"."user_id" WHERE ( ( ("auth_user__registrationprofile"."program_id" = 6 AND "auth_user__registrationprofile"."student_info_id" IS NOT NULL) OR "auth_user__satprepreginfo"."program_id" = 6 ) ) On Feb 3, 6:46 pm, "Mike Axiak" <[EMAIL PROTECTED]> wrote: > Hey, > I'm using Django release (currently 0.95.0, waiting for etch to move > to 0.95.1) with some patches (lazyuser patch comes to mind) on an > internal development. > > The question is, I was trying to do some Q object combinations and was > met with some weird results: > > y = Q(satprepreginfo__program = program) > > z = Q(registrationprofile__program = program) & \ > Q(registrationprofile__student_info__isnull = False) > > This is my result: > > In [27]: User.objects.filter(y | z).filter(username = 'mlopes') > Out[27]: [] > > In [28]: User.objects.filter(y).filter(username = 'mlopes') > Out[28]: [<User: mlopes>] > > Note that > In [24]: User.objects.filter(y|z).distinct().count() > Out[24]: 194L > > In [25]: User.objects.filter(y).distinct().count() > Out[25]: 198L > > So I am getting something as a result, but I just chose to filter one > user that has an interesting property. > Question: Am I doing something wrong? Is this a bug/feature/expected > behavior? > > Any help would be appreciated. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---