]> source.dussan.org Git - gitea.git/commitdiff
Fix bug on getIssueIDsByRepoID (#16119)
authorLunny Xiao <xiaolunwen@gmail.com>
Thu, 10 Jun 2021 00:08:19 +0000 (08:08 +0800)
committerGitHub <noreply@github.com>
Thu, 10 Jun 2021 00:08:19 +0000 (02:08 +0200)
* Fix bug on getIssueIDsByRepoID

* Add test

models/issue.go
models/issue_test.go

index 6912df6c28ac772ca65f01c82c14ee95d1c03e0f..760aaaab09694cfe7b27b73ff683bfac38bae02d 100644 (file)
@@ -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
 }
 
index c21b1d6ae98e6671c39d3c7e191ae3156dffd63e..b612ab267b43bed185d96fbb2bccaa70f27acc06 100644 (file)
@@ -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)