Opened 12 years ago

Last modified 10 years ago

#19195 closed Bug

Using distinct([*fields]) filter on a foreign key produces an ordering error when the foreign key has a Meta ordering field. — at Initial Version

Reported by: chrisedgemon@… Owned by: nobody
Component: Database layer (models, ORM) Version: 1.7-beta-2
Severity: Release blocker Keywords: distinct, query
Cc: Simon Charette Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I tried to using a distinct filter like this: Appearance.objects.order_by('team').distinct('team'); this fails with the following Database Error: "DatabaseError: SELECT DISTINCT ON expressions must match initial ORDER BY expressions"

It is possible to work around this problem by using this modified filter: Appearance.objects.order_by('teamid').distinct('teamid').

Model definition: http://pastebin.com/index/J45fy9fr
Full traceback: http://pastebin.com/feSFMbzX

Change History (0)

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