#6422: Support for 'DISTINCT ON' queries with QuerySet.distinct()
-------------------------------------+-------------------------------------
Reporter: Manfred | Owner: jgelens
Wassmann <manolo@…> | Status: assigned
Type: New | Component: Database layer
feature | (models, ORM)
Milestone: | Severity: Normal
Version: SVN | Keywords: dceu2011
Resolution: | Has patch: 1
Triage Stage: Accepted | Needs tests: 0
Needs documentation: 0 | Easy pickings: 0
Patch needs improvement: 1 |
UI/UX: 0 |
-------------------------------------+-------------------------------------
Changes (by tmitchell):
* needs_better_patch: 0 => 1
* stage: Ready for checkin => Accepted
Comment:
There's an interplay between DISTINCT ON and ORDER BY that isn't clear. I
was trying to nail it down before I replied but I got stuck, sorry about
that.
To demonstrate, if you use the models from tests.regressiontests.queries
and try to do: `Tag.objects.distinct('parent')` you get an error because
the default ordering for `Tag` is by 'name'. I am not sure how to
rectify this. Doing `Tag.objects.order_by('parent').distinct('parent')`
doesn't work either. If this isn't a bug, then the docs should be
expanded.
--
Ticket URL: <https://code.djangoproject.com/ticket/6422#comment:36>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en.