1
0

Explicitly check if there are Ids before trying to get items by a list of Ids

This commit is contained in:
kolaente
2021-03-02 18:40:39 +01:00
parent 3999580fe6
commit 6de3d8b3a1
10 changed files with 61 additions and 18 deletions

View File

@ -96,12 +96,20 @@ func ListUsersFromList(s *xorm.Session, l *List, search string) (users []*user.U
uids = append(uids, id)
}
var cond builder.Cond = builder.Like{"username", "%" + search + "%"}
if len(uids) > 0 {
cond = builder.And(
builder.In("id", uids),
cond,
)
}
// Get all users
err = s.
Table("users").
Select("*").
In("id", uids).
And("username LIKE ?", "%"+search+"%").
Where(cond).
GroupBy("id").
OrderBy("id").
Find(&users)