fix(views): include order by fields in distinct clause when sorting by task position
This commit is contained in:
parent
e7d6ee2392
commit
fa137b1ffc
@ -261,8 +261,13 @@ func (d *dbTaskSearcher) Search(opts *taskSearchOptions) (tasks []*Task, totalCo
|
|||||||
limit, start := getLimitFromPageIndex(opts.page, opts.perPage)
|
limit, start := getLimitFromPageIndex(opts.page, opts.perPage)
|
||||||
cond := builder.And(builder.Or(projectIDCond, favoritesCond), where, filterCond)
|
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.
|
query := d.s.
|
||||||
Distinct("tasks.*").
|
Distinct(distinct).
|
||||||
Where(cond)
|
Where(cond)
|
||||||
if limit > 0 {
|
if limit > 0 {
|
||||||
query = query.Limit(limit, start)
|
query = query.Limit(limit, start)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user