mirror of
https://github.com/navidrome/navidrome.git
synced 2025-04-04 13:07:36 +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{
|
All{
|
||||||
StartsWith{"comment": "this"},
|
StartsWith{"comment": "this"},
|
||||||
InTheRange{"year": []int{1980, 1990}},
|
InTheRange{"year": []int{1980, 1990}},
|
||||||
|
IsNot{"genre": "test"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Sort: "title",
|
Sort: "title",
|
||||||
|
@ -43,7 +44,8 @@ var _ = Describe("Criteria", func() {
|
||||||
},
|
},
|
||||||
{ "all": [
|
{ "all": [
|
||||||
{ "startsWith": {"comment": "this"} },
|
{ "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() {
|
It("generates valid SQL", func() {
|
||||||
sql, args, err := goObj.ToSql()
|
sql, args, err := goObj.ToSql()
|
||||||
gomega.Expect(err).ToNot(gomega.HaveOccurred())
|
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(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))
|
gomega.Expect(args).To(gomega.ConsistOf("%love%", "%hate%", "u2", "best of", "this%", 1980, 1990, "test"))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("marshals to JSON", func() {
|
It("marshals to JSON", func() {
|
||||||
|
|
|
@ -40,7 +40,7 @@ var fieldMap = map[string]*mappedField{
|
||||||
"bitrate": {field: "media_file.bit_rate"},
|
"bitrate": {field: "media_file.bit_rate"},
|
||||||
"bpm": {field: "media_file.bpm"},
|
"bpm": {field: "media_file.bpm"},
|
||||||
"channels": {field: "media_file.channels"},
|
"channels": {field: "media_file.channels"},
|
||||||
"genre": {field: "genre.name"},
|
"genre": {field: "COALESCE(genre.name, '')"},
|
||||||
"loved": {field: "COALESCE(annotation.starred, false)"},
|
"loved": {field: "COALESCE(annotation.starred, false)"},
|
||||||
"dateloved": {field: "annotation.starred_at"},
|
"dateloved": {field: "annotation.starred_at"},
|
||||||
"lastplayed": {field: "annotation.play_date"},
|
"lastplayed": {field: "annotation.play_date"},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue