Skip to content

Commit ee4bf00

Browse files
committed
Don't use format in SQL
1 parent 5e08120 commit ee4bf00

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

models/repo.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,9 @@ func repoStatsCorrectNumClosedPulls(ctx context.Context, id int64) error {
127127
return repo_model.UpdateRepoIssueNumbers(ctx, id, true, true)
128128
}
129129

130-
func statsQuery(args ...any) func(context.Context) ([]map[string][]byte, error) {
130+
func statsQuery(sql string, args ...any) func(context.Context) ([]map[string][]byte, error) {
131131
return func(ctx context.Context) ([]map[string][]byte, error) {
132-
return db.GetEngine(ctx).Query(args...)
132+
return db.GetEngine(ctx).Query(append([]any{sql}, args...)...)
133133
}
134134
}
135135

@@ -200,8 +200,8 @@ func CheckRepoStats(ctx context.Context) error {
200200
},
201201
// Issue.NumComments
202202
{
203-
statsQuery(fmt.Sprintf("SELECT `issue`.id FROM `issue` WHERE `issue`.num_comments!=(SELECT COUNT(*) FROM `comment` WHERE issue_id=`issue`.id AND (type=%d OR type=%d))",
204-
issues_model.ConversationCountedCommentType()...)),
203+
statsQuery("SELECT `issue`.id FROM `issue` WHERE `issue`.num_comments!=(SELECT COUNT(*) FROM `comment` WHERE issue_id=`issue`.id AND (type=? OR type=?))",
204+
issues_model.ConversationCountedCommentType()...),
205205
repoStatsCorrectIssueNumComments,
206206
"issue count 'num_comments'",
207207
},

0 commit comments

Comments
 (0)