1
0
mirror of https://github.com/go-gitea/gitea.git synced 2025-01-19 14:03:40 +03:00

Don't use format in SQL

This commit is contained in:
Lunny Xiao 2024-12-29 17:03:57 -08:00
parent 5e08120d3e
commit ee4bf009eb
No known key found for this signature in database
GPG Key ID: C3B7C91B632F738A

View File

@ -127,9 +127,9 @@ func repoStatsCorrectNumClosedPulls(ctx context.Context, id int64) error {
return repo_model.UpdateRepoIssueNumbers(ctx, id, true, true)
}
func statsQuery(args ...any) func(context.Context) ([]map[string][]byte, error) {
func statsQuery(sql string, args ...any) func(context.Context) ([]map[string][]byte, error) {
return func(ctx context.Context) ([]map[string][]byte, error) {
return db.GetEngine(ctx).Query(args...)
return db.GetEngine(ctx).Query(append([]any{sql}, args...)...)
}
}
@ -200,8 +200,8 @@ func CheckRepoStats(ctx context.Context) error {
},
// Issue.NumComments
{
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))",
issues_model.ConversationCountedCommentType()...)),
statsQuery("SELECT `issue`.id FROM `issue` WHERE `issue`.num_comments!=(SELECT COUNT(*) FROM `comment` WHERE issue_id=`issue`.id AND (type=? OR type=?))",
issues_model.ConversationCountedCommentType()...),
repoStatsCorrectIssueNumComments,
"issue count 'num_comments'",
},