Re: [Django] #13312: Add a way to customize the order_by() of null fields

31 views
Skip to first unread message

Django

unread,
Mar 31, 2016, 9:34:51 AM3/31/16
to django-...@googlegroups.com
#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
-------------------------------------+-------------------------------------
Changes (by ionelmc):

* cc: contact@… (added)


--
Ticket URL: <https://code.djangoproject.com/ticket/13312#comment:8>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Apr 21, 2016, 11:29:05 AM4/21/16
to django-...@googlegroups.com
#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
-------------------------------------+-------------------------------------
Changes (by int-ua):

* cc: serhiy.int@… (added)


--
Ticket URL: <https://code.djangoproject.com/ticket/13312#comment:9>

Django

unread,
Apr 21, 2016, 11:38:31 AM4/21/16
to django-...@googlegroups.com
#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

unread,
Jun 23, 2016, 12:09:10 PM6/23/16
to django-...@googlegroups.com
#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
-------------------------------------+-------------------------------------
Changes (by giuliettamasina):

* cc: markus.magnuson@… (added)


--
Ticket URL: <https://code.djangoproject.com/ticket/13312#comment:11>

Django

unread,
Jun 26, 2016, 7:57:14 PM6/26/16
to django-...@googlegroups.com
#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
-------------------------------------+-------------------------------------
Changes (by jarshwah):

* cc: josh.smeaton@… (added)


--
Ticket URL: <https://code.djangoproject.com/ticket/13312#comment:12>

Django

unread,
Jul 11, 2016, 2:35:40 PM7/11/16
to django-...@googlegroups.com
#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
-------------------------------------+-------------------------------------
Changes (by Naddiseo):

* cc: github@… (added)


--
Ticket URL: <https://code.djangoproject.com/ticket/13312#comment:13>

Django

unread,
Jul 27, 2016, 9:53:04 AM7/27/16
to django-...@googlegroups.com
#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: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by charettes):

* has_patch: 0 => 1


Comment:

[https://github.com/django/django/pull/6981 PR]

--
Ticket URL: <https://code.djangoproject.com/ticket/13312#comment:14>

Django

unread,
Aug 9, 2016, 2:24:14 PM8/9/16
to django-...@googlegroups.com
#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: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by timgraham):

* needs_better_patch: 0 => 1


Comment:

Comments for improvement are on the PR. Please uncheck "Patch needs
improvement" after you update it an add documentation (see our
PatchReviewChecklist).

--
Ticket URL: <https://code.djangoproject.com/ticket/13312#comment:15>

Django

unread,
Aug 22, 2016, 6:35:54 AM8/22/16
to django-...@googlegroups.com
#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: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by charettes):

* needs_better_patch: 1 => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/13312#comment:16>

Django

unread,
Sep 2, 2016, 10:55:07 AM9/2/16
to django-...@googlegroups.com
#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: 1 | Needs documentation: 1

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by timgraham):

* needs_docs: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/13312#comment:17>

Django

unread,
Sep 16, 2016, 8:11:30 PM9/16/16
to django-...@googlegroups.com
#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: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by timgraham):

* needs_docs: 1 => 0
* needs_better_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/13312#comment:18>

Django

unread,
Nov 16, 2016, 7:02:27 AM11/16/16
to django-...@googlegroups.com
#13312: Add a way to customize the order_by() of null fields
-------------------------------------+-------------------------------------
Reporter: Sergey Dobrov | 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: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

* needs_better_patch: 1 => 0


Comment:

[https://github.com/django/django/pull/7563 Updated PR]

--
Ticket URL: <https://code.djangoproject.com/ticket/13312#comment:19>

Django

unread,
Nov 16, 2016, 2:02:04 PM11/16/16
to django-...@googlegroups.com
#13312: Add a way to customize the order_by() of null fields
-------------------------------------+-------------------------------------
Reporter: Sergey Dobrov | Owner: felixxm
Type: New feature | Status: assigned

Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: ordering, order_by, | Triage Stage: Accepted
null |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by felixxm):

* status: new => assigned
* owner: nobody => felixxm


--
Ticket URL: <https://code.djangoproject.com/ticket/13312#comment:20>

Django

unread,
Dec 6, 2016, 9:25:16 AM12/6/16
to django-...@googlegroups.com
#13312: Add a way to customize the order_by() of null fields
-------------------------------------+-------------------------------------
Reporter: Sergey Dobrov | Owner: felixxm
Type: New feature | Status: assigned
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: ordering, order_by, | Triage Stage: Ready for
null | checkin

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Simon Charette):

* stage: Accepted => Ready for checkin


Comment:

Looking good pending some cosmetic changes.

--
Ticket URL: <https://code.djangoproject.com/ticket/13312#comment:21>

Django

unread,
Dec 8, 2016, 10:19:57 AM12/8/16
to django-...@googlegroups.com
#13312: Add a way to customize the order_by() of null fields
-------------------------------------+-------------------------------------
Reporter: Sergey Dobrov | Owner: felixxm
Type: New feature | Status: closed

Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution: fixed

Keywords: ordering, order_by, | Triage Stage: Ready for
null | checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham <timograham@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"47ef8f31f30a2b1920f82494d729c285565867dd" 47ef8f3]:
{{{
#!CommitTicketReference repository=""
revision="47ef8f31f30a2b1920f82494d729c285565867dd"
Fixed #13312 -- Allowed specifying the order of null fields in queries.

Thanks Mariusz Felisiak for finishing the patch.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/13312#comment:22>

Django

unread,
Dec 8, 2016, 9:43:18 PM12/8/16
to django-...@googlegroups.com
#13312: Add a way to customize the order_by() of null fields
-------------------------------------+-------------------------------------
Reporter: Sergey Dobrov | Owner: felixxm
Type: New feature | Status: closed
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution: fixed
Keywords: ordering, order_by, | Triage Stage: Ready for
null | checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Cloudream):

What about one parameter with three possible values?

nulls_first:

- True: nulls at first
- False: nulls at last
- None (default): database default ordering

--
Ticket URL: <https://code.djangoproject.com/ticket/13312#comment:23>

Django

unread,
Dec 8, 2016, 9:48:51 PM12/8/16
to django-...@googlegroups.com
#13312: Add a way to customize the order_by() of null fields
-------------------------------------+-------------------------------------
Reporter: Sergey Dobrov | Owner: felixxm
Type: New feature | Status: closed
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution: fixed
Keywords: ordering, order_by, | Triage Stage: Ready for
null | checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Josh Smeaton):

I don't like the idea of three-value logic here, because it imposes a
slight burden when reading. It just seems unnecessary when there's nothing
wrong with two kwarg options.

--
Ticket URL: <https://code.djangoproject.com/ticket/13312#comment:24>

Django

unread,
Dec 9, 2016, 3:44:10 AM12/9/16
to django-...@googlegroups.com
#13312: Add a way to customize the order_by() of null fields
-------------------------------------+-------------------------------------
Reporter: Sergey Dobrov | Owner: felixxm
Type: New feature | Status: closed
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution: fixed
Keywords: ordering, order_by, | Triage Stage: Ready for
null | checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Simon Charette):

@Cloudream see the discussion on the original
[https://github.com/django/django/pull/6981 PR] about why `nulls_first`
and `nulls_last` were chosen.

--
Ticket URL: <https://code.djangoproject.com/ticket/13312#comment:25>

Django

unread,
Oct 31, 2019, 3:17:57 PM10/31/19
to django-...@googlegroups.com
#13312: Add a way to customize the order_by() of null fields
-------------------------------------+-------------------------------------
Reporter: Sergey Dobrov | Owner: felixxm
Type: New feature | Status: closed
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution: fixed
Keywords: ordering, order_by, | Triage Stage: Ready for
null | checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Mariusz Felisiak <felisiak.mariusz@…>):

In [changeset:"a699595fce27d5d9c45ba83c656319593c366be9" a699595f]:
{{{
#!CommitTicketReference repository=""
revision="a699595fce27d5d9c45ba83c656319593c366be9"
Refs #13312 -- Removed unnecessary IF wrapping in nulls_last handling on
MySQL.

ISNULL function already returns 0 and 1 on MySQL.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/13312#comment:26>

Django

unread,
Nov 4, 2019, 8:49:07 AM11/4/19
to django-...@googlegroups.com
#13312: Add a way to customize the order_by() of null fields
-------------------------------------+-------------------------------------
Reporter: Sergey Dobrov | Owner: felixxm
Type: New feature | Status: closed
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution: fixed
Keywords: ordering, order_by, | Triage Stage: Ready for
null | checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Mariusz Felisiak <felisiak.mariusz@…>):

In [changeset:"7286eaf681d497167cd7dc8b70ceebfcf5cd21ad" 7286eaf]:
{{{
#!CommitTicketReference repository=""
revision="7286eaf681d497167cd7dc8b70ceebfcf5cd21ad"
Refs #13312 -- Simplified handling of nulls ordering on MySQL.

MySQL & MariaDB support the standard IS NULL and IS NOT NULL so
the same workaround used for NULLS FIRST and NULLS LAST that is
used for SQLite < 3.30.0 can be used.

Thanks Simon Charette for the discussion.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/13312#comment:27>

Reply all
Reply to author
Forward
0 new messages