Search: Support multiple order filters (#24230)

This commit is contained in:
Emil Tullstedt
2020-05-06 11:42:52 +02:00
committed by GitHub
parent 9b7bbc3d1c
commit 078d08d036
5 changed files with 57 additions and 19 deletions

View File

@@ -113,13 +113,14 @@ func (b *Builder) applyFilters() (ordering string) {
b.params = append(b.params, groupParams...)
}
if len(orders) > 0 {
orderBy := fmt.Sprintf(" ORDER BY %s", strings.Join(orders, ", "))
b.sql.WriteString(orderBy)
order := strings.Join(orderJoins, "")
order += orderBy
return order
if len(orders) < 1 {
orders = append(orders, TitleSorter{}.OrderBy())
}
return " ORDER BY dashboard.id"
orderBy := fmt.Sprintf(" ORDER BY %s", strings.Join(orders, ", "))
b.sql.WriteString(orderBy)
order := strings.Join(orderJoins, "")
order += orderBy
return order
}