#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
-------------------------------------+-------------------------------------

Comment (by Marcin Nowak):

 > Is there a reason you can't use ​conditional expressions

 No, but I didn't knew about the issue, and writing raw sqls is sometimes
 faster (not in this case ;)
 I'm really happy having possibility to mix raw sqls with object queries.
 Next time I'll use expressions, for sure.

 > Allowing the ordering optimization stuff to handle arbitrary RawSQL may
 be difficult.

 Personally I'd like to skip RawSQL clauses in the block which is
 responsible for finding duplicates. If someone is using raw sqls, he knows
 the best what he is doing, IMO. And it is quite strange if Django removes
 silently part of your SQL. This is very confusing. And please note that
 printing a `Query` instance was generating incomplete sql, but while
 checking `Query.order_by` manually, the return value was containing all
 clauses. I thought that just printing is affected, but our QA dept told me
 the truth ;)

 I know there is no effective way to compare similarity of two raw clauses.
 This may be hard for expression objects, too, but you have a possibility
 to implement some `__eq__` magic (instead of comparation of generated
 sqls). Unfortunately I don't know why duplicates detection was
 implemented, so it's hard to tell how to improve this part.

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

Reply via email to