Hi folks,
  When excluding using a subquery, I'm seeing the subquery being
executed first as its own query, then seeing the correct query being
run, including the subquery.  Using filter instead of exclude, this
does not happen.  Just wanted to see if I'm missing something obvious/
well known or if I should go ahead and file a bug (something I've not
yet done for Django :-)

Here's what I mean (Select fields edited out of the MySQL log for
readability- connection 374 is from the Python prompt, 332 is me
poking at the mysql command line in another window to make sure I
don't confuse which queries go with which python statements).  Version
info and a list of what I've researched already follows the example:

>>> baz=Publisher.objects.all()
>>> for s in Series.objects.filter(publisher__in=baz):
...   pass
...
>>> for s in Series.objects.exclude(publisher__in=baz):
...   pass
...
>>>

090509 19:30:22     332 Query       select count(*) from core_issue

090509 19:30:28     374 Query       SELECT * FROM `core_series` WHERE
`core_series`.`publisher_id` IN (SELECT U0.`id` FROM `core_publisher`
U0) ORDER BY `core_series`.`name` ASC, `core_series`.`year_began` ASC

090509 19:30:41     332 Query       select count(*) from core_issue

090509 19:30:54     374 Query       SELECT * FROM `core_publisher`
ORDER BY `core_publisher`.`name` ASC

090509 19:30:55     374 Query       SELECT * FROM `core_series` WHERE
NOT (`core_series`.`publisher_id` IN (SELECT U0.`id` FROM
`core_publisher` U0)) ORDER BY `core_series`.`name` ASC,
`core_series`.`year_began` ASC

Version stuff:
Django 1.1 beta 1
Mac OS X 10.4.11
MySQL 5.0.45
Python 2.4.4
MySQLdb 1.2.1_p2

Ran these searches against Django bugs (including closed bugs):
exclude
subquery
sub-query

Searches of this group:
exclude subquery
exclude sub-query
exclude __in

And I did read the docs on this, which mention that MySQL sometimes
does poorly with subqueries.  In the case I'm looking at, it does not.

thanks,
-henry



--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to