Code

Opened 5 years ago

Closed 5 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: UI/UX:

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.

Attachments (1)

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

Download all attachments as: .zip

Change History (5)

Changed 5 years ago by andrewl

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

comment:1 Changed 5 years ago by russellm

  • Description modified (diff)
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

Corrected formatting

comment:2 Changed 5 years ago by andrewl

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 Changed 5 years ago by jacob

  • Triage Stage changed from Unreviewed to Accepted

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

comment:4 Changed 5 years ago by mtredinnick

  • Resolution set to fixed
  • Status changed from new to 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.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.