From b7f534dbd7fd68920389faf03525f04e0a6de7c0 Mon Sep 17 00:00:00 2001 From: lng2020 Date: Wed, 18 Oct 2023 15:02:39 +0800 Subject: [PATCH 1/4] upgrade xorm --- go.mod | 2 +- go.sum | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 23474cd7e12ad..84f42969d50e5 100644 --- a/go.mod +++ b/go.mod @@ -121,7 +121,7 @@ require ( mvdan.cc/xurls/v2 v2.5.0 strk.kbt.io/projects/go/libravatar v0.0.0-20191008002943-06d1c002b251 xorm.io/builder v0.3.13 - xorm.io/xorm v1.3.3 + xorm.io/xorm v1.3.4-0.20231017094142-dbe499091a7e ) require ( diff --git a/go.sum b/go.sum index ec9527760cc5d..816b7db08f2a3 100644 --- a/go.sum +++ b/go.sum @@ -1650,3 +1650,5 @@ xorm.io/builder v0.3.13 h1:a3jmiVVL19psGeXx8GIurTp7p0IIgqeDmwhcR6BAOAo= xorm.io/builder v0.3.13/go.mod h1:aUW0S9eb9VCaPohFCH3j7czOx1PMW3i1HrSzbLYGBSE= xorm.io/xorm v1.3.3 h1:L5/GOhvgMcwJYYRjzPf3lTTTf6JcaTd1Mb9A/Iqvccw= xorm.io/xorm v1.3.3/go.mod h1:qFJGFoVYbbIdnz2vaL5OxSQ2raleMpyRRalnq3n9OJo= +xorm.io/xorm v1.3.4-0.20231017094142-dbe499091a7e h1:oL+ktEW+iSrCXU6IauJ9csZFATEmawkhsq/MAoHTdwo= +xorm.io/xorm v1.3.4-0.20231017094142-dbe499091a7e/go.mod h1:qFJGFoVYbbIdnz2vaL5OxSQ2raleMpyRRalnq3n9OJo= From d167ac7ec4d8babc7d80200b8d76d45011db6086 Mon Sep 17 00:00:00 2001 From: lng2020 Date: Wed, 18 Oct 2023 15:12:23 +0800 Subject: [PATCH 2/4] make tidy --- go.sum | 2 -- 1 file changed, 2 deletions(-) diff --git a/go.sum b/go.sum index 816b7db08f2a3..379533b08ced6 100644 --- a/go.sum +++ b/go.sum @@ -1648,7 +1648,5 @@ strk.kbt.io/projects/go/libravatar v0.0.0-20191008002943-06d1c002b251/go.mod h1: xorm.io/builder v0.3.11-0.20220531020008-1bd24a7dc978/go.mod h1:aUW0S9eb9VCaPohFCH3j7czOx1PMW3i1HrSzbLYGBSE= xorm.io/builder v0.3.13 h1:a3jmiVVL19psGeXx8GIurTp7p0IIgqeDmwhcR6BAOAo= xorm.io/builder v0.3.13/go.mod h1:aUW0S9eb9VCaPohFCH3j7czOx1PMW3i1HrSzbLYGBSE= -xorm.io/xorm v1.3.3 h1:L5/GOhvgMcwJYYRjzPf3lTTTf6JcaTd1Mb9A/Iqvccw= -xorm.io/xorm v1.3.3/go.mod h1:qFJGFoVYbbIdnz2vaL5OxSQ2raleMpyRRalnq3n9OJo= xorm.io/xorm v1.3.4-0.20231017094142-dbe499091a7e h1:oL+ktEW+iSrCXU6IauJ9csZFATEmawkhsq/MAoHTdwo= xorm.io/xorm v1.3.4-0.20231017094142-dbe499091a7e/go.mod h1:qFJGFoVYbbIdnz2vaL5OxSQ2raleMpyRRalnq3n9OJo= From d64023ec87eb67748dbf08a988ad0dea24eec1d4 Mon Sep 17 00:00:00 2001 From: lng2020 Date: Wed, 18 Oct 2023 18:57:42 +0800 Subject: [PATCH 3/4] When using GetCount, do not use OrderBy condition --- models/unittest/unit_tests.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/models/unittest/unit_tests.go b/models/unittest/unit_tests.go index 399040580cdcb..d47bceea1ea13 100644 --- a/models/unittest/unit_tests.go +++ b/models/unittest/unit_tests.go @@ -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) } From 7760c04f741e9d4274c000034a8e1bf3b2487adc Mon Sep 17 00:00:00 2001 From: lng2020 Date: Wed, 18 Oct 2023 22:20:43 +0800 Subject: [PATCH 4/4] add orderby 1 --- models/git/commit_status.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/git/commit_status.go b/models/git/commit_status.go index acb011020056e..c6a52bcd9f5b5 100644 --- a/models/git/commit_status.go +++ b/models/git/commit_status.go @@ -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