#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:
> I think we should raise `NotSupportedError` 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`. It
> cannot return correct result because columns from `ORDER BY` clause must
> be included in `SELECT`.
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.
--
--
Ticket URL: <https://code.djangoproject.com/ticket/28560#comment:7>
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/065.2c38b5a323bdf7c34eebfc9a996cf26f%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.