Make searching issues by keyword case insensitive on DB (#14848)
Most DBs apart from SQLite will use a default Collation that is not case insensitive. This means that SearchIssuesByKeyword becomes case sensitive for db indexing - in contrast to the bleve and elastic indexers. This PR simply uses UPPER(...) to do the LIKE - and although it may be more efficient to change collations this would be a non-trivial task. Fix #13663 Signed-off-by: Andrew Thornton <art27@cantab.net>release/v1.15
parent
f878c8231f
commit
def964e57f
|
@ -1706,17 +1706,18 @@ func GetRepoIssueStats(repoID, uid int64, filterMode int, isPull bool) (numOpen
|
||||||
func SearchIssueIDsByKeyword(kw string, repoIDs []int64, limit, start int) (int64, []int64, error) {
|
func SearchIssueIDsByKeyword(kw string, repoIDs []int64, limit, start int) (int64, []int64, error) {
|
||||||
var repoCond = builder.In("repo_id", repoIDs)
|
var repoCond = builder.In("repo_id", repoIDs)
|
||||||
var subQuery = builder.Select("id").From("issue").Where(repoCond)
|
var subQuery = builder.Select("id").From("issue").Where(repoCond)
|
||||||
|
kw = strings.ToUpper(kw)
|
||||||
var cond = builder.And(
|
var cond = builder.And(
|
||||||
repoCond,
|
repoCond,
|
||||||
builder.Or(
|
builder.Or(
|
||||||
builder.Like{"name", kw},
|
builder.Like{"UPPER(name)", kw},
|
||||||
builder.Like{"content", kw},
|
builder.Like{"UPPER(content)", kw},
|
||||||
builder.In("id", builder.Select("issue_id").
|
builder.In("id", builder.Select("issue_id").
|
||||||
From("comment").
|
From("comment").
|
||||||
Where(builder.And(
|
Where(builder.And(
|
||||||
builder.Eq{"type": CommentTypeComment},
|
builder.Eq{"type": CommentTypeComment},
|
||||||
builder.In("issue_id", subQuery),
|
builder.In("issue_id", subQuery),
|
||||||
builder.Like{"content", kw},
|
builder.Like{"UPPER(content)", kw},
|
||||||
)),
|
)),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
Loading…
Reference in New Issue