#13312: order_by on null-field gives different results on different db engines -------------------------------------+------------------------------------- Reporter: binary | Owner: nobody Type: Uncategorized | Status: new Component: Database layer | Version: 1.1 (models, ORM) | Severity: Normal | Resolution: Keywords: ordering, order_by, | Triage Stage: null | Unreviewed Has patch: 0 | Needs documentation: 0 Needs tests: 0 | Patch needs improvement: 0 Easy pickings: 0 | UI/UX: 0 -------------------------------------+------------------------------------- Changes (by jarshwah):
* status: closed => new * resolution: wontfix => Comment: Now that we have expressions, I think it's fine to reopen this ticket. We can introduce a `OrderNulls.last()/.first()` expression to handle this in a standard way. We could also just build it right into the `OrderBy` expression: {{{ qs.order_by(F('my_field').asc().nullslast()) }}} If we do build this into the existing order_by, you'll need to be careful about preserving a 'feature' that stops django from inserting duplicate ordering clauses (it builds each component then does a string compare to ensure the new clause isn't a duplicate). This won't normalise order by nulls across backends, but it'll allow users to control null handling semantics if they have a use for it. NULL handling was originally going to be added to the OrderBy expression, but I ran out of time before that could happen. -- Ticket URL: <https://code.djangoproject.com/ticket/13312#comment:6> 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/064.505cb8a853ae5d932ad05feee764810c%40djangoproject.com. For more options, visit https://groups.google.com/d/optout.