mirror of
https://github.com/navidrome/navidrome.git
synced 2026-06-02 07:01:36 +00:00
* fix(criteria): coerce string booleans in smart playlist rules - #4826 When clients (e.g. Feishin) send boolean values as strings ("true"/"false") in smart playlist JSON rules, the SQL comparison fails because SQLite stores booleans as 0/1 integers. For example, `COALESCE(annotation.starred, false) = 'true'` never matches. This adds a `boolean` flag to mapped fields and coerces string values to native Go bools in `mapFields`, so squirrel generates correct SQL parameters. Signed-off-by: mango766 <mango766@users.noreply.github.com> Signed-off-by: easonysliu <easonysliu@tencent.com> * fix(criteria): implement boolean string coercion for smart playlist rules Signed-off-by: Deluan <deluan@navidrome.org> --------- Signed-off-by: mango766 <mango766@users.noreply.github.com> Signed-off-by: easonysliu <easonysliu@tencent.com> Signed-off-by: Deluan <deluan@navidrome.org> Co-authored-by: easonysliu <easonysliu@tencent.com>
58 lines
1.5 KiB
Go
58 lines
1.5 KiB
Go
package criteria
|
|
|
|
import (
|
|
. "github.com/onsi/ginkgo/v2"
|
|
"github.com/onsi/gomega"
|
|
)
|
|
|
|
var _ = Describe("fields", func() {
|
|
Describe("LookupField", func() {
|
|
It("finds built-in fields case-insensitively", func() {
|
|
field, ok := LookupField("Title")
|
|
|
|
gomega.Expect(ok).To(gomega.BeTrue())
|
|
gomega.Expect(field.Name()).To(gomega.Equal("title"))
|
|
})
|
|
|
|
It("resolves aliases to their canonical field name", func() {
|
|
field, ok := LookupField("albumtype")
|
|
|
|
gomega.Expect(ok).To(gomega.BeTrue())
|
|
gomega.Expect(field.Name()).To(gomega.Equal("releasetype"))
|
|
gomega.Expect(field.IsTag).To(gomega.BeTrue())
|
|
})
|
|
|
|
It("finds registered tag names", func() {
|
|
AddTagNames([]string{"task3_mood"})
|
|
|
|
field, ok := LookupField("task3_mood")
|
|
|
|
gomega.Expect(ok).To(gomega.BeTrue())
|
|
gomega.Expect(field.Name()).To(gomega.Equal("task3_mood"))
|
|
gomega.Expect(field.IsTag).To(gomega.BeTrue())
|
|
})
|
|
|
|
It("marks registered numeric tags", func() {
|
|
AddTagNames([]string{"task3_score"})
|
|
AddNumericTags([]string{"task3_score"})
|
|
|
|
field, ok := LookupField("task3_score")
|
|
|
|
gomega.Expect(ok).To(gomega.BeTrue())
|
|
gomega.Expect(field.IsTag).To(gomega.BeTrue())
|
|
gomega.Expect(field.Numeric).To(gomega.BeTrue())
|
|
})
|
|
|
|
It("finds registered roles", func() {
|
|
AddRoles([]string{"task3_producer"})
|
|
|
|
field, ok := LookupField("task3_producer")
|
|
|
|
gomega.Expect(ok).To(gomega.BeTrue())
|
|
gomega.Expect(field.Name()).To(gomega.Equal("task3_producer"))
|
|
gomega.Expect(field.IsRole).To(gomega.BeTrue())
|
|
})
|
|
|
|
})
|
|
})
|