#28284: Paginator._check_object_list_is_ordered should not call __repr__ on
self.object_list
-----------------------------------------+------------------------
               Reporter:  Tom            |          Owner:  nobody
                   Type:  Uncategorized  |         Status:  new
              Component:  Core (Other)   |        Version:  1.11
               Severity:  Normal         |       Keywords:
           Triage Stage:  Unreviewed     |      Has patch:  0
    Needs documentation:  0              |    Needs tests:  0
Patch needs improvement:  0              |  Easy pickings:  0
                  UI/UX:  0              |
-----------------------------------------+------------------------
 The `_check_object_list_is_ordered` function in Paginator currently throws
 a warning if the queryset is unordered. As part of this warning the
 queryset is formatted using `{!r}`, which ends up calling the `__repr__`
 or `__str__` of each of the items in the QuerySet.

 This causes the entire queryset to be evaluated and all rows fetched, and
 if `__repr__` uses any foreign keys these are also fetched, resulting in a
 lot of queries. Warnings are also silent by default, and the string is
 *always* evaluated regardless of if the warning is displayed or not.

 Also, the warning is conditional: Pagination *may* yield inconsistent
 results. Some databases may vary, so to people who use these backends this
 change just introduced something that evaluates the entire queryset every
 time the Paginator is used for no particular reason.

 I propose that the warning is either replaced by a hard error, or the
 warning is changed to perhaps display the model name of the queryset, or
 some other information that doesn't require iterating the queryset.

--
Ticket URL: <https://code.djangoproject.com/ticket/28284>
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/046.71b5e9f72184db7d6f0d27f0d2b07278%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to