fix(pglite): keep the has_rating filter numeric

annotationBoolFilter serves both starred (boolean) and rating (integer);
the boolean form broke the Top Rated lists with 'COALESCE types integer
and boolean cannot be matched'.
This commit is contained in:
Deluan 2026-09-05 02:09:53 -04:00
commit ba088e7b14

View file

@ -95,7 +95,14 @@ func annotationBoolFilter(field string) func(string, any) Sqlizer {
if !ok {
return nil
}
return Expr(fmt.Sprintf("COALESCE(%s, false) = %t", field, strings.ToLower(v) == "true"))
set := strings.ToLower(v) == "true"
if field == "rating" { // integer column; starred is a boolean
if set {
return Expr("COALESCE(rating, 0) > 0")
}
return Expr("COALESCE(rating, 0) = 0")
}
return Expr(fmt.Sprintf("COALESCE(%s, false) = %t", field, set))
}
}