#6422: Support for 'DISTINCT ON' queries with QuerySet.distinct()
-------------------------------------+-------------------------------------
     Reporter:  Manfred Wassmann     |                    Owner:  jgelens
  <manolo@…>                         |                   Status:  assigned
         Type:  New feature          |                  Version:  SVN
    Component:  Database layer       |               Resolution:
  (models, ORM)                      |             Triage Stage:  Accepted
     Severity:  Normal               |      Needs documentation:  0
     Keywords:  dceu2011             |  Patch needs improvement:  0
    Has patch:  1                    |                    UI/UX:  0
  Needs tests:  0                    |
Easy pickings:  0                    |
-------------------------------------+-------------------------------------

Comment (by akaariai):

 Some comments (I haven't actually tried the patch, just read it in
 diffview):
  - IMHO add_distinct_fields needs a docstring. Other similar methods seem
 to have one, also.
  - What happens if you specify .distinct(field_list) multiple times with
 different fields? If the first .distinct call generated joins, won't those
 joins be left loitering around without any users, but still having
 refcount > 0?
  - Haven't tested this, but I suspect you can break this by adding fields
 to DISTINCT ON which aren't in the normal select list and then doing a
 group by. If you want correct results in this case, you will probably need
 to subquerify the DISTINCT ON query, then do a group by.
 NotImplementedError seems to be the sane choice, making this work
 correctly might be a bit hard and I haven't ever used distinct on + group
 by combination when writing SQL myself.

 The true_or_false argument was removed. Is there any way to get rid of the
 distinct after this. Does there need to be one?

-- 
Ticket URL: <https://code.djangoproject.com/ticket/6422#comment:57>
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.

Reply via email to