#13312: Add a way to customize the order_by() of null fields
-------------------------------------+-------------------------------------
     Reporter:  binary               |                    Owner:  nobody
         Type:  New feature          |                   Status:  new
    Component:  Database layer       |                  Version:  master
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:  ordering, order_by,  |             Triage Stage:  Accepted
  null                               |
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by int-ua):

 AFAIU, it's possible in all main supported engines:

 ORDER BY IF(ISNULL(my_field),1,0),my_field
 [http://forums.mysql.com/read.php?10,208709,208927 in MySQL]
 [NULLS { FIRST | LAST }] [http://www.postgresql.org/docs/8.3/static
 /queries-order.html in both PostgreSQL]
 [http://stackoverflow.com/questions/18698311/oracle-order-null-last-by-
 default and Oracle]
 ORDER BY col1 IS NULL [http://stackoverflow.com/questions/12503120/how-to-
 do-nulls-last-in-sqlite in SqLite3]

--
Ticket URL: <https://code.djangoproject.com/ticket/13312#comment:10>
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/064.0ac4a5840860459a7d963890968e80d2%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to