Skip to content

Commit 179c727

Browse files
authored
Fix bug on getIssueIDsByRepoID (#16119)
* Fix bug on getIssueIDsByRepoID * Add test
1 parent 5fef041 commit 179c727

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

models/issue.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1086,7 +1086,7 @@ func getIssuesByIDs(e Engine, issueIDs []int64) ([]*Issue, error) {
10861086

10871087
func getIssueIDsByRepoID(e Engine, repoID int64) ([]int64, error) {
10881088
ids := make([]int64, 0, 10)
1089-
err := e.Table("issue").Where("repo_id = ?", repoID).Find(&ids)
1089+
err := e.Table("issue").Cols("id").Where("repo_id = ?", repoID).Find(&ids)
10901090
return ids, err
10911091
}
10921092

models/issue_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,14 @@ func TestIssue_ReplaceLabels(t *testing.T) {
3636
testSuccess(1, []int64{})
3737
}
3838

39+
func Test_GetIssueIDsByRepoID(t *testing.T) {
40+
assert.NoError(t, PrepareTestDatabase())
41+
42+
ids, err := GetIssueIDsByRepoID(1)
43+
assert.NoError(t, err)
44+
assert.Len(t, ids, 5)
45+
}
46+
3947
func TestIssueAPIURL(t *testing.T) {
4048
assert.NoError(t, PrepareTestDatabase())
4149
issue := AssertExistsAndLoadBean(t, &Issue{ID: 1}).(*Issue)

0 commit comments

Comments
 (0)