Opened 15 years ago

Closed 15 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 Russell Keith-Magee)

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)

exclude_sql.txt (2.8 KB ) - added by andrewl 15 years ago.
Django v1.0.x SQL and error traceback vs Django Trunk SQL

Download all attachments as: .zip

Change History (5)

by andrewl, 15 years ago

Attachment: exclude_sql.txt added

Django v1.0.x SQL and error traceback vs Django Trunk SQL

comment:1 by Russell Keith-Magee, 15 years ago

Description: modified (diff)

Corrected formatting

comment:2 by andrewl, 15 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 Jacob, 15 years ago

Triage Stage: UnreviewedAccepted

It appears we must have missed backporting a query fix somewhere.

comment:4 by Malcolm Tredinnick, 15 years ago

Resolution: fixed
Status: newclosed

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.

Note: See TracTickets for help on using tickets.
Back to Top