Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue search with db indexer because of mysql 5.7 sqlmode #14907

Merged
merged 2 commits into from
Mar 6, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion models/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -1724,10 +1724,19 @@ func SearchIssueIDsByKeyword(kw string, repoIDs []int64, limit, start int) (int6
)

var ids = make([]int64, 0, limit)
err := x.Distinct("id").Table("issue").Where(cond).OrderBy("`updated_unix` DESC").Limit(limit, start).Find(&ids)
var res = make([]struct {
ID int64
UpdatedUnix int64
}, 0, limit)
err := x.Distinct("id", "updated_unix").Table("issue").Where(cond).
OrderBy("`updated_unix` DESC").Limit(limit, start).
Find(&res)
if err != nil {
return 0, nil, err
}
for _, r := range res {
ids = append(ids, r.ID)
}

total, err := x.Distinct("id").Table("issue").Where(cond).Count()
if err != nil {
Expand Down