fix(db): make paginated database reads always require "order" option (#39017)

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
silverwind
2026-08-23 10:18:18 +02:00
committed by GitHub
parent 0bed1232ee
commit 1c16f04bf5
29 changed files with 161 additions and 65 deletions
+1 -1
View File
@@ -161,7 +161,7 @@ func (opts FindArtifactsOptions) ToOrders() string {
return "id"
}
var _ db.FindOptionsOrder = (*FindArtifactsOptions)(nil)
var _ db.FindOptions = (*FindArtifactsOptions)(nil)
func (opts FindArtifactsOptions) ToConds() builder.Cond {
cond := builder.NewCond()
+3 -2
View File
@@ -13,6 +13,7 @@ import (
"gitea.dev/modules/container"
"gitea.dev/modules/optional"
"gitea.dev/modules/timeutil"
"gitea.dev/modules/util"
"xorm.io/builder"
)
@@ -155,10 +156,10 @@ func (opts FindRunJobOptions) ToJoins() []db.JoinFunc {
}
func (opts FindRunJobOptions) ToOrders() string {
return string(opts.OrderBy)
return util.IfZero(string(opts.OrderBy), "action_run_job.id")
}
var _ db.FindOptionsOrder = FindRunJobOptions{}
var _ db.FindOptions = (*FindRunJobOptions)(nil)
// CountRunJobsByRunAndAttemptID counts the jobs belonging to the given run attempt.
// It is used to enforce MaxJobNumPerRun when reusable-workflow expansion inserts new jobs.
+4
View File
@@ -53,6 +53,10 @@ type FindScopedWorkflowSourceOpts struct {
SourceRepoID int64
}
func (opts FindScopedWorkflowSourceOpts) ToOrders() string {
return "id"
}
func (opts FindScopedWorkflowSourceOpts) ToConds() builder.Cond {
cond := builder.NewCond()
if len(opts.OwnerIDs) > 0 {
+4
View File
@@ -79,6 +79,10 @@ type FindVariablesOpts struct {
Name string
}
func (opts FindVariablesOpts) ToOrders() string {
return "name"
}
func (opts FindVariablesOpts) ToConds() builder.Cond {
cond := builder.NewCond()