X.objects.filter(...) works, X.objects.exclude(...) fails in 1.0.x
|Reported by:||andrewl||Owned by:||nobody|
|Component:||Database layer (models, ORM)||Version:||1.0|
|Severity:||Keywords:||filter, exclude, SQL|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
Description (last modified by russellm)
While an X.objects.filter(...) works, the equivalent X.objects.exclude(...) fails under Django 1.0.x.
The exclusion condition seems to need at least 3 levels of 'redirection' (for want of a better term) for the failure to occur. For example:
X.objects.exclude(a='foo') -- OK X.objects.exclude(a__b='foo') -- OK X.objects.exclude(a__b__c='foo') -- FAIL
The equivalent X.objects.filter(...) succeeds. Also I have not tested higher levels of redirection than 3.
Note that this appears to be fixed in Django TRUNK (which was at revision 9821 at the time of submitting this ticket).
Please refer to the attached file for a concrete query example showing the SQL produced under Django 1.0.x (tagged releases 1.0 and 1.0.2 tested) and Django TRUNK.
Change History (5)
Changed 7 years ago by andrewl
comment:1 Changed 7 years ago by russellm
- Description modified (diff)
- Needs documentation unset
- Needs tests unset
- Patch needs improvement unset