Opened 16 years ago
Closed 16 years ago
#10233 closed (fixed)
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 | |
Cc: | Triage Stage: | Accepted | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
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.
Attachments (1)
Change History (5)
by , 16 years ago
Attachment: | exclude_sql.txt added |
---|
comment:2 by , 16 years ago
As a side note, this was initially tested with PostgreSQL as the DB, but it also fails with SQLite. Have not tested with MySQL.
comment:3 by , 16 years ago
Triage Stage: | Unreviewed → Accepted |
---|
It appears we must have missed backporting a query fix somewhere.
comment:4 by , 16 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
This was fixed by r9591 on the 1.0.X branch. It's not enough to test the latest release when checking for behavioural differences (unless you also test trunk from the same time), since that was a few months ago and we've fixed bugs since then. The fix will be the Django 1.0.3 release.
Django v1.0.x SQL and error traceback vs Django Trunk SQL