#26225: Coalesce Multiple Calls to order_by with Same Arguments
-------------------------------------+-------------------------------------
     Reporter:  cancan101            |                    Owner:  nobody
         Type:                       |                   Status:  new
  Cleanup/optimization               |
    Component:  Database layer       |                  Version:  1.9
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     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 mjtamlyn):

 Yes, this would make significant unnecessary complexity in my opinion. The
 ORM currently abides by a simple rule that chaining on another call
 creates a new queryset. We even explicitly use this with  `all()` in
 `forms.ModelChoiceField` - and that's an API which can ''never'' change
 the queryset.

 It's worth noting that you could add this kind of behaviour to a custom
 queryset class, but you would be inspecting private properties of the
 underlying query object to get what you want. Looking at the original
 ticket you opened, how I would approach that sort of situation where a you
 have code which may have a prefetched query or may not is to use `to_attr`
 - prefetch to `_ordered_children` and then have a `ordered_children`
 method which returns `_ordered_children` if it exists, or runs the query
 if not.

--
Ticket URL: <https://code.djangoproject.com/ticket/26225#comment:2>
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/067.3f53996ec782b605bd9f9b84d05c74ac%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to