From 30a37311f85b3058c8c5b94427208281568eba91 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Sat, 12 Nov 2016 16:29:18 +0800 Subject: [PATCH] use in instead string join (#155) --- models/admin.go | 3 +-- models/issue.go | 2 +- models/issue_label.go | 6 ++---- models/ssh_key.go | 3 +-- 4 files changed, 5 insertions(+), 9 deletions(-) diff --git a/models/admin.go b/models/admin.go index 605e21babc..14a0e8d009 100644 --- a/models/admin.go +++ b/models/admin.go @@ -14,7 +14,6 @@ import ( "github.com/Unknwon/com" "github.com/go-xorm/xorm" - "code.gitea.io/gitea/modules/base" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" ) @@ -131,7 +130,7 @@ func DeleteNoticesByIDs(ids []int64) error { return nil } _, err := x. - Where("id IN (" + strings.Join(base.Int64sToStrings(ids), ",") + ")"). + In("id", ids). Delete(new(Notice)) return err } diff --git a/models/issue.go b/models/issue.go index 16766fc6c3..40b96da658 100644 --- a/models/issue.go +++ b/models/issue.go @@ -829,7 +829,7 @@ func Issues(opts *IssuesOptions) ([]*Issue, error) { return make([]*Issue, 0), nil } sess. - In("issue.repo_id", base.Int64sToStrings(opts.RepoIDs)). + In("issue.repo_id", opts.RepoIDs). And("issue.is_closed=?", opts.IsClosed) } else { sess.Where("issue.is_closed=?", opts.IsClosed) diff --git a/models/issue_label.go b/models/issue_label.go index a42219d888..3eed8ed985 100644 --- a/models/issue_label.go +++ b/models/issue_label.go @@ -14,8 +14,6 @@ import ( "github.com/go-xorm/xorm" api "code.gitea.io/sdk/gitea" - - "code.gitea.io/gitea/modules/base" ) var labelColorPattern = regexp.MustCompile("#([a-fA-F0-9]{6})") @@ -140,7 +138,7 @@ func GetLabelsInRepoByIDs(repoID int64, labelIDs []int64) ([]*Label, error) { labels := make([]*Label, 0, len(labelIDs)) return labels, x. Where("repo_id = ?", repoID). - In("id", base.Int64sToStrings(labelIDs)). + In("id", labelIDs). Asc("name"). Find(&labels) } @@ -170,7 +168,7 @@ func getLabelsByIssueID(e Engine, issueID int64) ([]*Label, error) { labels := make([]*Label, 0, len(labelIDs)) return labels, e. Where("id > 0"). - In("id", base.Int64sToStrings(labelIDs)). + In("id", labelIDs). Asc("name"). Find(&labels) } diff --git a/models/ssh_key.go b/models/ssh_key.go index 8670ac11c8..4a6acb8ecf 100644 --- a/models/ssh_key.go +++ b/models/ssh_key.go @@ -22,7 +22,6 @@ import ( "github.com/go-xorm/xorm" "golang.org/x/crypto/ssh" - "code.gitea.io/gitea/modules/base" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/process" "code.gitea.io/gitea/modules/setting" @@ -476,7 +475,7 @@ func deletePublicKeys(e *xorm.Session, keyIDs ...int64) error { return nil } - _, err := e.In("id", strings.Join(base.Int64sToStrings(keyIDs), ",")).Delete(new(PublicKey)) + _, err := e.In("id", keyIDs).Delete(new(PublicKey)) return err }