diff --git a/pkg/models/task_collection.go b/pkg/models/task_collection.go index f6a22a121a4..c2936ff7086 100644 --- a/pkg/models/task_collection.go +++ b/pkg/models/task_collection.go @@ -74,7 +74,8 @@ func validateTaskField(fieldName string) error { taskPropertyUpdated, taskPropertyPosition, taskPropertyKanbanPosition, - taskPropertyBucketID: + taskPropertyBucketID, + taskPropertyIndex: return nil } return ErrInvalidTaskField{TaskField: fieldName} diff --git a/pkg/models/task_collection_sort.go b/pkg/models/task_collection_sort.go index 7b72cc2090b..4badd799b79 100644 --- a/pkg/models/task_collection_sort.go +++ b/pkg/models/task_collection_sort.go @@ -46,6 +46,7 @@ const ( taskPropertyPosition string = "position" taskPropertyKanbanPosition string = "kanban_position" taskPropertyBucketID string = "bucket_id" + taskPropertyIndex string = "index" ) const ( diff --git a/pkg/models/tasks.go b/pkg/models/tasks.go index 707e065909c..e86e7d6acf7 100644 --- a/pkg/models/tasks.go +++ b/pkg/models/tasks.go @@ -309,10 +309,10 @@ 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 { - orderby += param.sortBy + " IS NULL, " + orderby += "`" + param.sortBy + "` IS NULL, " } - orderby += param.sortBy + " " + param.orderBy.String() + orderby += "`" + param.sortBy + "` " + param.orderBy.String() // 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.