fix(server): fix case-insensitive sort order and add indexes to improve performance (#3425)
* refactor(server): better sort mappings * refactor(server): simplify GetIndex * fix: recreate tables and indexes using proper collation Also add tests to ensure proper collation * chore: remove unused method * fix: sort expressions * fix: lint errors * fix: cleanup
This commit is contained in:
@@ -81,3 +81,13 @@ func (e existsCond) ToSql() (string, []interface{}, error) {
|
||||
}
|
||||
return sql, args, err
|
||||
}
|
||||
|
||||
var sortOrderRegex = regexp.MustCompile(`order_([a-z_]+)`)
|
||||
|
||||
// Convert the order_* columns to an expression using sort_* columns. Example:
|
||||
// sort_album_name -> (coalesce(nullif(sort_album_name,”),order_album_name) collate nocase)
|
||||
// It finds order column names anywhere in the substring
|
||||
func mapSortOrder(order string) string {
|
||||
order = strings.ToLower(order)
|
||||
return sortOrderRegex.ReplaceAllString(order, "(coalesce(nullif(sort_$1,''),order_$1) collate nocase)")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user