Search: sort results correctly when using postgres (#46466)

* Search: sort results correctly when using postgres

postgresql puts nulls first while both mysql and sqlite puts them last

* linting
This commit is contained in:
Leonard Gram
2022-03-15 15:08:40 +01:00
committed by GitHub
parent 16cf179df1
commit f46038ed3a
3 changed files with 25 additions and 1 deletions

View File

@@ -140,7 +140,12 @@ func (b *Builder) applyFilters() (ordering string) {
b.params = append(b.params, groupParams...)
}
orderBy := fmt.Sprintf(" ORDER BY %s", strings.Join(orders, ", "))
orderByCols := []string{}
for _, o := range orders {
orderByCols = append(orderByCols, b.Dialect.OrderBy(o))
}
orderBy := fmt.Sprintf(" ORDER BY %s", strings.Join(orderByCols, ", "))
b.sql.WriteString(orderBy)
order := strings.Join(orderJoins, "")