Fix for #1176 The query builder was querying with sub_category=0 when sub was not supplied
Cette révision appartient à :
Parent
405df46cf0
révision
64d9bfcded
2 fichiers modifiés avec 12 ajouts et 4 suppressions
|
@ -142,9 +142,15 @@ func byQueryPostgres(c *gin.Context, pagenum int, countAll bool, withUser bool,
|
|||
if len(search.Category) > 0 {
|
||||
conditionsOr := make([]string, len(search.Category))
|
||||
for key, val := range search.Category {
|
||||
conditionsOr[key] = "(category = ? AND sub_category = ?)"
|
||||
parameters.Params = append(parameters.Params, val.Main)
|
||||
parameters.Params = append(parameters.Params, val.Sub)
|
||||
if val.Main > 0 {
|
||||
conditionsOr[key] = "(category = ?"
|
||||
parameters.Params = append(parameters.Params, val.Main)
|
||||
if val.Sub > 0 {
|
||||
conditionsOr[key] += " AND sub_category = ?"
|
||||
parameters.Params = append(parameters.Params, val.Sub)
|
||||
}
|
||||
conditionsOr[key] += ")"
|
||||
}
|
||||
}
|
||||
conditions = append(conditions, strings.Join(conditionsOr, " OR "))
|
||||
}
|
||||
|
|
|
@ -106,7 +106,9 @@ func (p *TorrentParam) ToFilterQuery() string {
|
|||
if val.IsSubSet() {
|
||||
conditionsOr[key] = "(category: " + strconv.FormatInt(int64(val.Main), 10) + " AND sub_category: " + strconv.FormatInt(int64(val.Sub), 10) + ")"
|
||||
} else {
|
||||
conditionsOr[key] = "(category: " + strconv.FormatInt(int64(val.Main), 10) + ")"
|
||||
if val.Main > 0 {
|
||||
conditionsOr[key] = "(category: " + strconv.FormatInt(int64(val.Main), 10) + ")"
|
||||
}
|
||||
}
|
||||
}
|
||||
query += "(" + strings.Join(conditionsOr, " OR ") + ")"
|
||||
|
|
Référencer dans un nouveau ticket