fix(server): fix numeric comparisons for float custom tags in smart playlists (#4116)

* Fix numeric comparisons for custom float tags

* feat(criteria): cast numeric tags for sorting and comparisons

Signed-off-by: Deluan <deluan@navidrome.org>

---------

Signed-off-by: Deluan <deluan@navidrome.org>
This commit is contained in:
Deluan Quintão
2025-05-25 17:52:27 -04:00
committed by GitHub
parent fac9275c27
commit 5e2db2c673
6 changed files with 69 additions and 6 deletions
+4
View File
@@ -4,6 +4,7 @@ package criteria
import (
"encoding/json"
"errors"
"fmt"
"strings"
"github.com/Masterminds/squirrel"
@@ -40,6 +41,9 @@ func (c Criteria) OrderBy() string {
} else {
mapped = f.field
}
if f.numeric {
mapped = fmt.Sprintf("CAST(%s AS REAL)", mapped)
}
}
if c.Order != "" {
if strings.EqualFold(c.Order, "asc") || strings.EqualFold(c.Order, "desc") {