#29692: Incorrect removal of order_by clause created as multiline RawSQL
-------------------------------------+-------------------------------------
     Reporter:  Marcin Nowak         |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  Database layer       |                  Version:  1.11
  (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
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

 * type:  Uncategorized => Bug


Comment:

 Is there a reason you can't use
 [https://docs.djangoproject.com/en/dev/ref/models/conditional-
 expressions/#case conditional expressions], e.g. something like:
 {{{
 MyModel.objects.annotate(
     custom_order=Case(
         When(...),
     )
 ).order_by('custom_order')
 }}}
 I'm thinking that would avoid fiddly `ordering_parts` regular expression.

 If there's some shortcoming to that approach, it might be easier to
 address that. Allowing the ordering optimization stuff to handle arbitrary
 RawSQL may be difficult.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/29692#comment:1>
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/065.353540c5c4b5f82ca67b72a60a3eb5b8%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to