2022-07-28 22:28:04 +05:30
|
|
|
// Copyright 2022 The Gitea Authors. All rights reserved.
|
2022-11-27 23:50:29 +05:30
|
|
|
// SPDX-License-Identifier: MIT
|
2022-07-28 22:28:04 +05:30
|
|
|
|
|
|
|
package db
|
|
|
|
|
|
|
|
import (
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
"code.gitea.io/gitea/modules/setting"
|
|
|
|
"code.gitea.io/gitea/modules/util"
|
|
|
|
|
|
|
|
"xorm.io/builder"
|
|
|
|
)
|
|
|
|
|
|
|
|
// BuildCaseInsensitiveLike returns a condition to check if the given value is like the given key case-insensitively.
|
|
|
|
// Handles especially SQLite correctly as UPPER there only transforms ASCII letters.
|
|
|
|
func BuildCaseInsensitiveLike(key, value string) builder.Cond {
|
|
|
|
if setting.Database.UseSQLite3 {
|
|
|
|
return builder.Like{"UPPER(" + key + ")", util.ToUpperASCII(value)}
|
|
|
|
}
|
|
|
|
return builder.Like{"UPPER(" + key + ")", strings.ToUpper(value)}
|
|
|
|
}
|