1 | | 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). |
| 1 | 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`. |
| 2 | |
| 3 | After some discussion on the mailing list (https://groups.google.com/g/django-developers/c/DNVRFqVBsfk/m/xDUvaq3DAAAJ) it looks like the consensus is to require an explicit opt-in or raise an error (i.e., never add a column implicitly if the user specified a list of columns via values() or values_list()). |