From 41a4047e79b593b32a6a3e4fc55ca4788190e71e Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Thu, 10 Jun 2021 13:12:18 +0800 Subject: [PATCH] Fix bug on getIssueIDsByRepoID (#16119) (#16124) * Fix bug on getIssueIDsByRepoID * Add test --- models/issue.go | 2 +- models/issue_test.go | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/models/issue.go b/models/issue.go index 6912df6c2..760aaaab0 100644 --- a/models/issue.go +++ b/models/issue.go @@ -1086,7 +1086,7 @@ func getIssuesByIDs(e Engine, issueIDs []int64) ([]*Issue, error) { func getIssueIDsByRepoID(e Engine, repoID int64) ([]int64, error) { ids := make([]int64, 0, 10) - err := e.Table("issue").Where("repo_id = ?", repoID).Find(&ids) + err := e.Table("issue").Cols("id").Where("repo_id = ?", repoID).Find(&ids) return ids, err } diff --git a/models/issue_test.go b/models/issue_test.go index c21b1d6ae..b612ab267 100644 --- a/models/issue_test.go +++ b/models/issue_test.go @@ -36,6 +36,14 @@ func TestIssue_ReplaceLabels(t *testing.T) { testSuccess(1, []int64{}) } +func Test_GetIssueIDsByRepoID(t *testing.T) { + assert.NoError(t, PrepareTestDatabase()) + + ids, err := GetIssueIDsByRepoID(1) + assert.NoError(t, err) + assert.Len(t, ids, 5) +} + func TestIssueAPIURL(t *testing.T) { assert.NoError(t, PrepareTestDatabase()) issue := AssertExistsAndLoadBean(t, &Issue{ID: 1}).(*Issue)