Fix Player filter

This commit is contained in:
Deluan 2024-08-05 18:21:21 -04:00
parent 290333ec59
commit eaa7f7c7e9
4 changed files with 7 additions and 5 deletions

View file

@ -23,7 +23,7 @@ func NewGenreRepository(ctx context.Context, db dbx.Builder) model.GenreReposito
r.db = db
r.tableName = "genre"
r.filterMappings = map[string]filterFunc{
"name": containsFilter,
"name": containsFilter("name"),
}
return r
}

View file

@ -21,7 +21,7 @@ func NewPlayerRepository(ctx context.Context, db dbx.Builder) model.PlayerReposi
r.db = db
r.tableName = "player"
r.filterMappings = map[string]filterFunc{
"name": containsFilter,
"name": containsFilter("player.name"),
}
return r
}

View file

@ -24,7 +24,7 @@ func NewRadioRepository(ctx context.Context, db dbx.Builder) model.RadioReposito
r.db = db
r.tableName = "radio"
r.filterMappings = map[string]filterFunc{
"name": containsFilter,
"name": containsFilter("name"),
}
r.sortMappings = map[string]string{
"name": "(name collate nocase), name",

View file

@ -59,8 +59,10 @@ func startsWithFilter(field string, value interface{}) Sqlizer {
return Like{field: fmt.Sprintf("%s%%", value)}
}
func containsFilter(field string, value interface{}) Sqlizer {
return Like{field: fmt.Sprintf("%%%s%%", value)}
func containsFilter(field string) func(string, any) Sqlizer {
return func(_ string, value any) Sqlizer {
return Like{field: fmt.Sprintf("%%%s%%", value)}
}
}
func booleanFilter(field string, value interface{}) Sqlizer {