Skip to content

Commit 5ccf8b6

Browse files
authored
Fix issue search with db indexer because of mysql 5.7 sqlmode (#14907)
* Fix sqlmode bug * distinct is necessary
1 parent f4efa10 commit 5ccf8b6

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

models/issue.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1724,10 +1724,19 @@ func SearchIssueIDsByKeyword(kw string, repoIDs []int64, limit, start int) (int6
17241724
)
17251725

17261726
var ids = make([]int64, 0, limit)
1727-
err := x.Distinct("id").Table("issue").Where(cond).OrderBy("`updated_unix` DESC").Limit(limit, start).Find(&ids)
1727+
var res = make([]struct {
1728+
ID int64
1729+
UpdatedUnix int64
1730+
}, 0, limit)
1731+
err := x.Distinct("id", "updated_unix").Table("issue").Where(cond).
1732+
OrderBy("`updated_unix` DESC").Limit(limit, start).
1733+
Find(&res)
17281734
if err != nil {
17291735
return 0, nil, err
17301736
}
1737+
for _, r := range res {
1738+
ids = append(ids, r.ID)
1739+
}
17311740

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

0 commit comments

Comments
 (0)