fix: make author search case insenstive (#6782)

- Make the author search in the issues and pull request list case
insenstive.
- Background: Forgejo mandates that all columns are case senstive and
only SQLite ignores this for ASCII characters with the `LIKE` operator
any other database will indeed do case senstive searching. Codeberg
recently made all columns case senstive, hence why this issue now surfaces.
- Added integration test.
- Resolves forgejo/forgejo#6744

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/6782
Reviewed-by: Beowulf <beowulf@beocode.eu>
Co-authored-by: Gusted <postmaster@gusted.xyz>
Co-committed-by: Gusted <postmaster@gusted.xyz>
This commit is contained in:
Gusted 2025-02-04 16:33:47 +00:00 committed by Gusted
parent 5b26596c5c
commit 499497c959
2 changed files with 45 additions and 2 deletions

View file

@ -166,9 +166,9 @@ func GetReviewers(ctx context.Context, repo *Repository, doerID, posterID int64)
// If isShowFullName is set to true, also include full name prefix search
func GetIssuePostersWithSearch(ctx context.Context, repo *Repository, isPull bool, search string, isShowFullName bool) ([]*user_model.User, error) {
users := make([]*user_model.User, 0, 30)
var prefixCond builder.Cond = builder.Like{"name", search + "%"}
prefixCond := db.BuildCaseInsensitiveLike("name", search+"%")
if isShowFullName {
prefixCond = prefixCond.Or(builder.Like{"full_name", "%" + search + "%"})
prefixCond = db.BuildCaseInsensitiveLike("full_name", "%"+search+"%")
}
cond := builder.In("`user`.id",