﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
33543	Depracate passing False to OrderBy's nulls_first and nulls_last.	Gordon Wrigley	AllenJonathan	"Consider the following:

{{{
In [11]: [tv.published_at for tv in TemplateVersion.objects.order_by(F(""published_at"").desc(nulls_first=True))]
Out[11]: 
[None,
 datetime.datetime(2022, 2, 25, 13, 0, 12, 91916, tzinfo=<UTC>),
 datetime.datetime(2022, 2, 21, 10, 18, 0, 169248, tzinfo=<UTC>)]

In [12]: [tv.published_at for tv in TemplateVersion.objects.order_by(F(""published_at"").desc(nulls_first=False))]
Out[12]: 
[None,
 datetime.datetime(2022, 2, 25, 13, 0, 12, 91916, tzinfo=<UTC>),
 datetime.datetime(2022, 2, 21, 10, 18, 0, 169248, tzinfo=<UTC>)]

In [13]: [tv.published_at for tv in TemplateVersion.objects.order_by(F(""published_at"").desc(nulls_last=True))]
Out[13]: 
[datetime.datetime(2022, 2, 25, 13, 0, 12, 91916, tzinfo=<UTC>),
 datetime.datetime(2022, 2, 21, 10, 18, 0, 169248, tzinfo=<UTC>),
 None]

In [14]: [tv.published_at for tv in TemplateVersion.objects.order_by(F(""published_at"").desc(nulls_last=False))]
Out[14]: 
[None,
 datetime.datetime(2022, 2, 25, 13, 0, 12, 91916, tzinfo=<UTC>),
 datetime.datetime(2022, 2, 21, 10, 18, 0, 169248, tzinfo=<UTC>)]
}}}

Observe how `nulls_first=False` still puts the nulls first.

This happens because they both default False and when they are both False it lets the DB decide.

This is surprising behaviour, it also makes changing the null positioning based on a variable more awkward than it needs to be.

I think it would be better if they defaulted to None, let the DB decide when both are None and when one is not None do the ordering that implies. "	Cleanup/optimization	closed	Database layer (models, ORM)	3.2	Normal	fixed			Accepted	1	0	0	0	0	0
