{{{
def test_values_with_default_ordering(self):
qs = Article.objects.values('author').distinct()
self.assertEqual(qs.count(), len(qs.order_by())) # OK
self.assertEqual(qs.count(), len(qs)) # FAIL: 1 != 4
}}}
Even though this behaviour
[https://docs.djangoproject.com/en/4.0/ref/models/querysets/#distinct is
documented], it's quite unexpected that the default ordering still impacts
such queries, even after fixing #14357. In #32811 it has been noted that
"the previous behavior [before #14357] was implicit, unexpected, and
caused many support questions". Probably the same could be said in this
case. So shouldn't this also be fixed?
--
Ticket URL: <https://code.djangoproject.com/ticket/33429>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* status: new => closed
* type: Bug => Cleanup/optimization
* resolution: => duplicate
Comment:
Duplicate of #33382 and #30655. We need to reach a strong consensus on the
DevelopersMailingList and deprecate the current (documented) behavior
before we can move it forward. You can raise the idea on the
DevelopersMailingList to reach a wider audience and see what other think.
--
Ticket URL: <https://code.djangoproject.com/ticket/33429#comment:1>