#34251: Paginator should warn if ordering is not deterministic
----------------------------------------------+------------------------
               Reporter:  Alexandr Tatarinov  |          Owner:  nobody
                   Type:  New feature         |         Status:  new
              Component:  Core (Other)        |        Version:  4.1
               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                   |
----------------------------------------------+------------------------
 As documented in tickets #28657 and #28261, at least some database
 backends will produce non-deterministic ordering when sorting by columns
 with non-unique values.
 This leads to inconsistent pagination, which I argue falls under the same
 category as paginating by unordered QuerySet. To make things worse, this
 one is easy to overlook, since non-unique columns like "name" can have
 mostly unique values and you need to have duplicates at the page borders
 to observe the issue, so it's more likely to happen in production
 environments after operating fine for quite a while.

 I suggest we add a warning similar to the UnorderedObjectListWarning when
 total ordering as defined
 
[https://github.com/django/django/blob/main/django/contrib/admin/views/main.py#L390
 in admin changelist] is not specified.

 The outstanding question is, how to realistically deal with this situation
 when ordering is provided by the end-user? It's typical to have i.e. "sort
 by price asc/desc" option in the UI or API, which will result in a warning
 since the price is not a unique column. Pushing responsibility to add "pk"
 to each sorting option to the front end does not seem like a reasonable
 way to me. This may be out of the scope of the current ticket, but I want
 to make sure we have a plan. I would say we also shouldn't insert pk
 automatically like ChangeList does, it'll at least break indexing as in
 this ticket #29943. Would like to hear your thoughts.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/34251>
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/01070185a0443b3c-35a1d0b5-9529-4288-8743-8660dadb57d6-000000%40eu-central-1.amazonses.com.

Reply via email to