diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2021-06-10 08:08:19 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-10 02:08:19 +0200 |
commit | 179c727b4f4475c29a882502c8d7084aaf633900 (patch) | |
tree | a583252523acff05c10a3213b11004e146340696 /models | |
parent | 5fef041079d8524537e24e8afc5d2b8c2579600c (diff) | |
download | gitea-179c727b4f4475c29a882502c8d7084aaf633900.tar.gz gitea-179c727b4f4475c29a882502c8d7084aaf633900.zip |
Fix bug on getIssueIDsByRepoID (#16119)
* Fix bug on getIssueIDsByRepoID
* Add test
Diffstat (limited to 'models')
-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 6912df6c28..760aaaab09 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 c21b1d6ae9..b612ab267b 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) |