#17974: .distint('FIELDNAME') FAILS for MySQL -------------------------------------+------------------------------------- Reporter: mschettler@… | Owner: nobody Type: Bug | Status: closed Component: Database layer | Version: 1.4 (models, ORM) | Resolution: invalid Severity: Normal | Triage Stage: Keywords: distinct on | Unreviewed Has patch: 1 | Needs documentation: 0 Needs tests: 0 | Patch needs improvement: 0 Easy pickings: 0 | UI/UX: 0 -------------------------------------+-------------------------------------
Comment (by akaariai): If you can make .distinct('somefield') work on MySQL it would be very welcome addition. I believe it is somewhat hard to write that patch correctly (particularly, how to make .order_by() + .distinct() work correctly). MySQL doesn't have DISTINCT ON (fields), so you need something like this: http://stackoverflow.com/questions/5804529/distinct-on- multiple-columns. Of course, if you want just distinct somefield values, instead of the full DISTINCT ON semantics, then qs.values_list('somefield').distinct() should work. Why is there DISTINCT ON implementation that works only on PostgreSQL? The choice was to not support this at all, or support this only on PostgreSQL. The distinct(*fields) is very useful in certain cases, so I think having it on PostgreSQL only is better than not having it at all. -- Ticket URL: <https://code.djangoproject.com/ticket/17974#comment:9> 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 unsubscribe from this group and stop receiving emails from it, send an email to django-updates+unsubscr...@googlegroups.com. To post to this group, send email to django-updates@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/078.77f08408d333e244d4477b8c2156cb70%40djangoproject.com?hl=en. For more options, visit https://groups.google.com/groups/opt_out.