Opened 16 years ago

Closed 16 years ago

Last modified 13 years ago

#7181 closed (fixed)

Meta ordering on foreign key field which can be None

Reported by: kkulewski@… Owned by: nobody
Component: Database layer (models, ORM) Version: dev
Severity: Keywords: qsrf-cleanup
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I have model A which links to model B (using field b, but A.b can be None). In Meta of A I have ordering set to b.

AFAIK simple A.objects.all() select query contains INNER JOIN (in this case I use sqlite, but probably this problem is more popular) with relation B so if for some instance of A, A.b is None then it will be not included in the results of A.objects.all().

Change History (5)

comment:1 by Rudolph Froger, 16 years ago

I can confirm that this is also a problem for me (PostgreSQL, latest trunk). See:
my example

comment:2 by George Vilches, 16 years ago

Keywords: qsrf-cleanup added

comment:3 by Jacob, 16 years ago

milestone: 1.0

comment:4 by Malcolm Tredinnick, 16 years ago

Resolution: fixed
Status: newclosed

(In [7761]) Fixed #7181 -- when ordering by a potentially NULL field, use a left-outer join
so that the ordering doesn't accidentally restrict the result set.

(Ironically, one existing test actually showed this problem, but I was too
dumb to notice the result was incorrect.)

comment:5 by Jacob, 13 years ago

milestone: 1.0

Milestone 1.0 deleted

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