From 9421f1848f4c3dd4796404fd687087a742f13d08 Mon Sep 17 00:00:00 2001 From: kolaente Date: Sat, 28 May 2022 11:04:50 +0200 Subject: [PATCH] fix: always sort nulls last --- pkg/models/tasks.go | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/pkg/models/tasks.go b/pkg/models/tasks.go index ee9a74fdf..a9f9443fb 100644 --- a/pkg/models/tasks.go +++ b/pkg/models/tasks.go @@ -301,12 +301,7 @@ func getRawTasksForLists(s *xorm.Session, lists []*List, a web.Auth, opts *taskO // Because it does not have support for NULLS FIRST or NULLS LAST we work around this by // first sorting for null (or not null) values and then the order we actually want to. if db.Type() == schemas.MYSQL { - if param.orderBy == orderAscending { - orderby += param.sortBy + " IS NULL, " - } - if param.orderBy == orderDescending { - orderby += param.sortBy + " IS NOT NULL, " - } + orderby += param.sortBy + " IS NULL, " } orderby += param.sortBy + " " + param.orderBy.String() @@ -314,12 +309,7 @@ func getRawTasksForLists(s *xorm.Session, lists []*List, a web.Auth, opts *taskO // Postgres and sqlite allow us to control how columns with null values are sorted. // To make that consistent with the sort order we have and other dbms, we're adding a separate clause here. if db.Type() == schemas.POSTGRES || db.Type() == schemas.SQLITE { - if param.orderBy == orderAscending { - orderby += " NULLS LAST" - } - if param.orderBy == orderDescending { - orderby += " NULLS FIRST" - } + orderby += " NULLS LAST" } if (i + 1) < len(opts.sortby) {