summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2021-06-10 08:08:19 +0800
committerGitHub <noreply@github.com>2021-06-10 02:08:19 +0200
commit179c727b4f4475c29a882502c8d7084aaf633900 (patch)
treea583252523acff05c10a3213b11004e146340696 /models
parent5fef041079d8524537e24e8afc5d2b8c2579600c (diff)
downloadgitea-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.go2
-rw-r--r--models/issue_test.go8
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)