Skip to content

Commit def964e

Browse files
authored
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 <[email protected]>
1 parent f878c82 commit def964e

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

models/issue.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1706,17 +1706,18 @@ func GetRepoIssueStats(repoID, uid int64, filterMode int, isPull bool) (numOpen
17061706
func SearchIssueIDsByKeyword(kw string, repoIDs []int64, limit, start int) (int64, []int64, error) {
17071707
var repoCond = builder.In("repo_id", repoIDs)
17081708
var subQuery = builder.Select("id").From("issue").Where(repoCond)
1709+
kw = strings.ToUpper(kw)
17091710
var cond = builder.And(
17101711
repoCond,
17111712
builder.Or(
1712-
builder.Like{"name", kw},
1713-
builder.Like{"content", kw},
1713+
builder.Like{"UPPER(name)", kw},
1714+
builder.Like{"UPPER(content)", kw},
17141715
builder.In("id", builder.Select("issue_id").
17151716
From("comment").
17161717
Where(builder.And(
17171718
builder.Eq{"type": CommentTypeComment},
17181719
builder.In("issue_id", subQuery),
1719-
builder.Like{"content", kw},
1720+
builder.Like{"UPPER(content)", kw},
17201721
)),
17211722
),
17221723
),

0 commit comments

Comments
 (0)