#30655: len(queryset) and queryset.count() return different results.
-------------------------------------+-------------------------------------
Reporter: Sander Kleijwegt | Owner: nobody
Type: Bug | Status: closed
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution: wontfix
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Huub Bouma):
I think it's crazy that an order_by changes the amount of records in the
resulting queryset..
Here's a workaround to achieve the sorting without duplicate records in
the queryset:
{{{
from django.db.models import Max
Bar.objects.all().annotate(ordered_fooint=Max('foos__fooint')).order_by('ordered_fooint'))
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/30655#comment:5>
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 view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/01070183408b05e4-b890ef80-f44c-4420-90bb-ff2e5c380662-000000%40eu-central-1.amazonses.com.