fix(views): include order by fields in distinct clause when sorting by task position
continuous-integration/drone/pr Build is failing Details

This commit is contained in:
kolaente 2024-03-19 17:05:12 +01:00
parent e7d6ee2392
commit fa137b1ffc
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
1 changed files with 6 additions and 1 deletions

View File

@ -261,8 +261,13 @@ func (d *dbTaskSearcher) Search(opts *taskSearchOptions) (tasks []*Task, totalCo
limit, start := getLimitFromPageIndex(opts.page, opts.perPage)
cond := builder.And(builder.Or(projectIDCond, favoritesCond), where, filterCond)
var distinct = "tasks.*"
if strings.Contains(orderby, "task_positions.") {
distinct += ", task_positions.position"
}
query := d.s.
Distinct("tasks.*").
Distinct(distinct).
Where(cond)
if limit > 0 {
query = query.Limit(limit, start)