1
0
Fork 0
forked from forgejo/forgejo

Upgrade xorm (#27673) (#27691)

Backport #27673 by @lng2020

Related to https://gitea.com/xorm/xorm/pulls/2341

Co-authored-by: Nanguan Lin <70063547+lng2020@users.noreply.github.com>
This commit is contained in:
Giteabot 2023-10-19 18:56:39 +08:00 committed by GitHub
parent 9b14f1a8ed
commit 89d3766d22
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 5 deletions

View file

@ -235,7 +235,7 @@ func GetCommitStatuses(ctx context.Context, repo *repo_model.Repository, sha str
countSession := listCommitStatusesStatement(ctx, repo, sha, opts)
countSession = db.SetSessionPagination(countSession, opts)
maxResults, err := countSession.Count(new(CommitStatus))
maxResults, err := countSession.OrderBy("1").Count(new(CommitStatus))
if err != nil {
log.Error("Count PRs: %v", err)
return nil, maxResults, err

View file

@ -96,7 +96,15 @@ func AssertExistsAndLoadMap(t assert.TestingT, table string, conditions ...any)
// GetCount get the count of a bean
func GetCount(t assert.TestingT, bean any, conditions ...any) int {
e := db.GetEngine(db.DefaultContext)
count, err := whereOrderConditions(e, conditions).Count(bean)
for _, condition := range conditions {
switch cond := condition.(type) {
case *testCond:
e = e.Where(cond.query, cond.args...)
default:
e = e.Where(cond)
}
}
count, err := e.Count(bean)
assert.NoError(t, err)
return int(count)
}