#9759: exclude() does not return the opposite of filter() for one to many
relationships
---------------------------------------------------+------------------------
Reporter: gregplaysguitar | Owner:
mtredinnick
Status: assigned | Milestone:
Component: Database layer (models, ORM) | Version: 1.0
Resolution: | Keywords: "not
equal", exclude, filter
Stage: Unreviewed | Has_patch: 0
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 0 |
---------------------------------------------------+------------------------
Changes (by mtredinnick):
* owner: nobody => mtredinnick
* needs_better_patch: => 0
* status: new => assigned
* needs_tests: => 0
* needs_docs: => 0
Comment:
You never want anything involving the word "equality" when working with
NULLs, since they don't compare equal to anything. Fortunately, there's
already the `__isnull` lookup type, so filtering on `career__isnull=False`
will do what you want (it will generate the latter SQL). Spotting that the
`exclude()` call you wrote is a special case that can be transformed into
the `__isnull` equivalent is not something Django will do -- it's quite
complex to spot such transformations efficiently and always make the
correct one.
I cannot immediately spot the problem with the `exclude()` call, however.
Since I'm working on this area, I'll add this to my test cases.
--
Ticket URL: <http://code.djangoproject.com/ticket/9759#comment:1>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" 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-updates?hl=en
-~----------~----~----~----~------~----~------~--~---