mirror of
https://github.com/navidrome/navidrome.git
synced 2025-04-03 20:47:35 +03:00
Coalesce genre to null for smart playlist (#2573)
This commit is contained in:
parent
59f0c487e7
commit
77ace8570c
2 changed files with 6 additions and 4 deletions
|
@ -23,6 +23,7 @@ var _ = Describe("Criteria", func() {
|
|||
All{
|
||||
StartsWith{"comment": "this"},
|
||||
InTheRange{"year": []int{1980, 1990}},
|
||||
IsNot{"genre": "test"},
|
||||
},
|
||||
},
|
||||
Sort: "title",
|
||||
|
@ -43,7 +44,8 @@ var _ = Describe("Criteria", func() {
|
|||
},
|
||||
{ "all": [
|
||||
{ "startsWith": {"comment": "this"} },
|
||||
{ "inTheRange": {"year":[1980,1990]} }
|
||||
{ "inTheRange": {"year":[1980,1990]} },
|
||||
{ "isNot": { "genre": "test" }}
|
||||
]
|
||||
}
|
||||
],
|
||||
|
@ -62,8 +64,8 @@ var _ = Describe("Criteria", func() {
|
|||
It("generates valid SQL", func() {
|
||||
sql, args, err := goObj.ToSql()
|
||||
gomega.Expect(err).ToNot(gomega.HaveOccurred())
|
||||
gomega.Expect(sql).To(gomega.Equal("(media_file.title LIKE ? AND media_file.title NOT LIKE ? AND (media_file.artist <> ? OR media_file.album = ?) AND (media_file.comment LIKE ? AND (media_file.year >= ? AND media_file.year <= ?)))"))
|
||||
gomega.Expect(args).To(gomega.ConsistOf("%love%", "%hate%", "u2", "best of", "this%", 1980, 1990))
|
||||
gomega.Expect(sql).To(gomega.Equal("(media_file.title LIKE ? AND media_file.title NOT LIKE ? AND (media_file.artist <> ? OR media_file.album = ?) AND (media_file.comment LIKE ? AND (media_file.year >= ? AND media_file.year <= ?) AND COALESCE(genre.name, '') <> ?))"))
|
||||
gomega.Expect(args).To(gomega.ConsistOf("%love%", "%hate%", "u2", "best of", "this%", 1980, 1990, "test"))
|
||||
})
|
||||
|
||||
It("marshals to JSON", func() {
|
||||
|
|
|
@ -40,7 +40,7 @@ var fieldMap = map[string]*mappedField{
|
|||
"bitrate": {field: "media_file.bit_rate"},
|
||||
"bpm": {field: "media_file.bpm"},
|
||||
"channels": {field: "media_file.channels"},
|
||||
"genre": {field: "genre.name"},
|
||||
"genre": {field: "COALESCE(genre.name, '')"},
|
||||
"loved": {field: "COALESCE(annotation.starred, false)"},
|
||||
"dateloved": {field: "annotation.starred_at"},
|
||||
"lastplayed": {field: "annotation.play_date"},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue