diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2021-03-06 23:11:12 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-06 23:11:12 +0800 |
commit | 5ccf8b64306fd6d695e6938fea7ad2f85df5717c (patch) | |
tree | 5b9db9f6b7ee37c9a9c25ab1b89c7a8d0b37db87 /models/issue.go | |
parent | f4efa10f779bd5cfdbf3dbcf21680245cf18c49b (diff) | |
download | gitea-5ccf8b64306fd6d695e6938fea7ad2f85df5717c.tar.gz gitea-5ccf8b64306fd6d695e6938fea7ad2f85df5717c.zip |
Fix issue search with db indexer because of mysql 5.7 sqlmode (#14907)
* Fix sqlmode bug
* distinct is necessary
Diffstat (limited to 'models/issue.go')
-rw-r--r-- | models/issue.go | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/models/issue.go b/models/issue.go index 58eb229f29..7ca8391029 100644 --- a/models/issue.go +++ b/models/issue.go @@ -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 { |