#28560: distinct() on ordered queryset with restricted list of columns returns incorrect result -------------------------------------+------------------------------------- Reporter: felixxm | Owner: felixxm Type: Bug | Status: assigned Component: Database layer | Version: master (models, ORM) | Severity: Normal | Resolution: Keywords: distinct values | Triage Stage: | Unreviewed Has patch: 0 | Needs documentation: 0 Needs tests: 0 | Patch needs improvement: 0 Easy pickings: 0 | UI/UX: 0 -------------------------------------+------------------------------------- Description changed by felixxm:
Old description: > When `distinct()` is used with `values()` (or `values_list()`) on ordered > queryset and a list of fields in `values()` doesn't contain all fields > from `ORDER BY`, then it doesn't return correct result because columns > from `ORDER BY` clause must be included in `SELECT`. As Simon suggested > we should wrap a query in a subquery. New description: When `distinct()` is used with `values()` (or `values_list()`) on ordered queryset and a list of fields in `values()` doesn't contain all fields from `ORDER BY`, then it doesn't return correct result because columns from `ORDER BY` clause must be included in `SELECT`. As Simon suggested we should wrap a query in a subquery (see related tickets #7070, #5321). -- -- Ticket URL: <https://code.djangoproject.com/ticket/28560#comment:8> 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/065.7d46848633d6bef80153ae17131720bc%40djangoproject.com. For more options, visit https://groups.google.com/d/optout.