mirror of
https://github.com/navidrome/navidrome.git
synced 2025-04-03 20:47:35 +03:00
Order albums by full original date. Fixes #1452
This commit is contained in:
parent
11f33ff8b6
commit
7d0656f44a
3 changed files with 12 additions and 6 deletions
|
@ -27,7 +27,7 @@ func NewAlbumRepository(ctx context.Context, o orm.QueryExecutor) model.AlbumRep
|
|||
"name": "order_album_name asc, order_album_artist_name asc",
|
||||
"artist": "compilation asc, order_album_artist_name asc, order_album_name asc",
|
||||
"random": "RANDOM()",
|
||||
"max_year": "max_year asc, name, order_album_name asc",
|
||||
"max_year": "max_year, coalesce(nullif(original_date, ''), nullif(release_date, '')), name, order_album_name asc",
|
||||
"recently_added": recentlyAddedSort(),
|
||||
}
|
||||
r.filterMappings = map[string]filterFunc{
|
||||
|
|
|
@ -97,14 +97,16 @@ func (r sqlRepository) buildSortOrder(sort, order string) string {
|
|||
}
|
||||
|
||||
func splitFunc(delimiter rune) func(c rune) bool {
|
||||
open := false
|
||||
open := 0
|
||||
return func(c rune) bool {
|
||||
if open {
|
||||
open = c != ')'
|
||||
if c == '(' {
|
||||
open++
|
||||
return false
|
||||
}
|
||||
if c == '(' {
|
||||
open = true
|
||||
if open > 0 {
|
||||
if c == ')' {
|
||||
open--
|
||||
}
|
||||
return false
|
||||
}
|
||||
return c == delimiter
|
||||
|
|
|
@ -69,6 +69,10 @@ var _ = Describe("sqlRepository", func() {
|
|||
sql := r.buildSortOrder("name desc, substr(id, 7), status asc", "desc")
|
||||
Expect(sql).To(Equal("name asc, substr(id, 7) desc, status desc"))
|
||||
})
|
||||
It("handles nested functions", func() {
|
||||
sql := r.buildSortOrder("name desc, coalesce(nullif(release_date, ''), nullif(original_date, '')), status asc", "desc")
|
||||
Expect(sql).To(Equal("name asc, coalesce(nullif(release_date, ''), nullif(original_date, '')) desc, status desc"))
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue