diff options
author | Lunny Xiao | 2021-06-10 13:12:18 +0800 |
---|---|---|
committer | GitHub | 2021-06-10 06:12:18 +0100 |
commit | 41a4047e79b593b32a6a3e4fc55ca4788190e71e (patch) | |
tree | afec1b323c5ed5f7c7efe6ffd3ff448546f3a795 | |
parent | ac84bb7183a58a60c056f4fa5f6059392339b41b (diff) |
Fix bug on getIssueIDsByRepoID (#16119) (#16124)
* Fix bug on getIssueIDsByRepoID
* Add test
-rw-r--r-- | models/issue.go | 2 | ||||
-rw-r--r-- | models/issue_test.go | 8 |
2 files changed, 9 insertions, 1 deletions
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) |