Search: Fix only searching for folder id zero (#44175)

Fixes so that searching for folder id zero in folder/dashboard search returns 
dashboards located in the general folder and not including all folders as it 
did before.

Fixes #40273
This commit is contained in:
Marcus Efraimsson
2022-01-21 13:51:58 +01:00
committed by GitHub
parent da98ebdcdf
commit 007cd144a9
3 changed files with 26 additions and 2 deletions
+7 -1
View File
@@ -87,10 +87,16 @@ func (f TitleFilter) Where() (string, []interface{}) {
}
type FolderFilter struct {
IDs []int64
Dialect migrator.Dialect
IDs []int64
}
func (f FolderFilter) Where() (string, []interface{}) {
if len(f.IDs) == 1 && f.IDs[0] == 0 {
sql := fmt.Sprintf("dashboard.folder_id = 0 AND dashboard.is_folder = %s", f.Dialect.BooleanStr(false))
return sql, []interface{}{}
}
return sqlIDin("dashboard.folder_id", f.IDs)
}