Skip to content

Commit aa9a99c

Browse files
authored
Upgrade xorm to latest to fix insert issue bug (#8309)
* upgrade xorm to latest to fix insert issue bug * add newissue unit tests * update xorm version * fix tests
1 parent c6fb7fe commit aa9a99c

File tree

14 files changed

+465
-75
lines changed

14 files changed

+465
-75
lines changed

go.mod

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ require (
4848
github.com/go-redis/redis v6.15.2+incompatible
4949
github.com/go-sql-driver/mysql v1.4.1
5050
github.com/go-swagger/go-swagger v0.20.1
51-
github.com/go-xorm/xorm v0.7.8-0.20190925172902-71947cf034b6
51+
github.com/go-xorm/xorm v0.7.8
5252
github.com/gobwas/glob v0.2.3
5353
github.com/gogits/chardet v0.0.0-20150115103509-2404f7772561
5454
github.com/gogs/cron v0.0.0-20171120032916-9f6c956d3e14
@@ -125,5 +125,5 @@ require (
125125
mvdan.cc/xurls/v2 v2.0.0
126126
strk.kbt.io/projects/go/libravatar v0.0.0-20160628055650-5eed7bff870a
127127
xorm.io/builder v0.3.6
128-
xorm.io/core v0.7.0
128+
xorm.io/core v0.7.2
129129
)

go.sum

+6-2
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,8 @@ github.com/go-swagger/scan-repo-boundary v0.0.0-20180623220736-973b3573c013/go.m
250250
github.com/go-xorm/sqlfiddle v0.0.0-20180821085327-62ce714f951a h1:9wScpmSP5A3Bk8V3XHWUcJmYTh+ZnlHVyc+A4oZYS3Y=
251251
github.com/go-xorm/sqlfiddle v0.0.0-20180821085327-62ce714f951a/go.mod h1:56xuuqnHyryaerycW3BfssRdxQstACi0Epw/yC5E2xM=
252252
github.com/go-xorm/xorm v0.7.6/go.mod h1:nqz2TAsuOHWH2yk4FYWtacCGgdbrcdZ5mF1XadqEHls=
253-
github.com/go-xorm/xorm v0.7.8-0.20190925172902-71947cf034b6 h1:kwKsKxuD8cUIOHWaMk5nuBU9ZUTnGpN2c/e4Mt6RTAo=
254-
github.com/go-xorm/xorm v0.7.8-0.20190925172902-71947cf034b6/go.mod h1:RSsmsVARCy4sayuKWFPaVNQMPYGLNRIK71YIVvgImL0=
253+
github.com/go-xorm/xorm v0.7.8 h1:rKxZJB9mWQ9Nw2TbjsepiThR031jkGePOWXwTtEAU08=
254+
github.com/go-xorm/xorm v0.7.8/go.mod h1:XiVxrMMIhFkwSkh96BW7PACl7UhLtx2iJIHMdmjh5sQ=
255255
github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y=
256256
github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8=
257257
github.com/gofrs/uuid v3.2.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
@@ -824,3 +824,7 @@ xorm.io/builder v0.3.6 h1:ha28mQ2M+TFx96Hxo+iq6tQgnkC9IZkM6D8w9sKHHF8=
824824
xorm.io/builder v0.3.6/go.mod h1:LEFAPISnRzG+zxaxj2vPicRwz67BdhFreKg8yv8/TgU=
825825
xorm.io/core v0.7.0 h1:hKxuOKWZNeiFQsSuGet/KV8HZ788hclvAl+7azx3tkM=
826826
xorm.io/core v0.7.0/go.mod h1:TuOJjIVa7e3w/rN8tDcAvuLBMtwzdHPbyOzE6Gk1EUI=
827+
xorm.io/core v0.7.2-0.20190928055935-90aeac8d08eb h1:msX3zG3BPl8Ti+LDzP33/9K7BzO/WqFXk610K1kYKfo=
828+
xorm.io/core v0.7.2-0.20190928055935-90aeac8d08eb/go.mod h1:jJfd0UAEzZ4t87nbQYtVjmqpIODugN6PD2D9E+dJvdM=
829+
xorm.io/core v0.7.2 h1:mEO22A2Z7a3fPaZMk6gKL/jMD80iiyNwRrX5HOv3XLw=
830+
xorm.io/core v0.7.2/go.mod h1:jJfd0UAEzZ4t87nbQYtVjmqpIODugN6PD2D9E+dJvdM=

models/issue_test.go

+33
Original file line numberDiff line numberDiff line change
@@ -320,3 +320,36 @@ func TestIssue_SearchIssueIDsByKeyword(t *testing.T) {
320320
assert.EqualValues(t, 1, total)
321321
assert.EqualValues(t, []int64{1}, ids)
322322
}
323+
324+
func testInsertIssue(t *testing.T, title, content string) {
325+
repo := AssertExistsAndLoadBean(t, &Repository{ID: 1}).(*Repository)
326+
user := AssertExistsAndLoadBean(t, &User{ID: 2}).(*User)
327+
328+
var issue = Issue{
329+
RepoID: repo.ID,
330+
PosterID: user.ID,
331+
Title: title,
332+
Content: content,
333+
}
334+
err := NewIssue(repo, &issue, nil, nil, nil)
335+
assert.NoError(t, err)
336+
337+
var newIssue Issue
338+
has, err := x.ID(issue.ID).Get(&newIssue)
339+
assert.NoError(t, err)
340+
assert.True(t, has)
341+
assert.EqualValues(t, issue.Title, newIssue.Title)
342+
assert.EqualValues(t, issue.Content, newIssue.Content)
343+
// there are 4 issues and max index is 4 on repository 1, so this one should 5
344+
assert.EqualValues(t, 5, newIssue.Index)
345+
346+
_, err = x.ID(issue.ID).Delete(new(Issue))
347+
assert.NoError(t, err)
348+
}
349+
350+
func TestIssue_InsertIssue(t *testing.T) {
351+
assert.NoError(t, PrepareTestDatabase())
352+
353+
testInsertIssue(t, "my issue1", "special issue's comments?")
354+
testInsertIssue(t, `my issue2, this is my son's love \n \r \ `, "special issue's '' comments?")
355+
}

vendor/github.com/go-xorm/xorm/.drone.yml

+196
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/go-xorm/xorm/go.mod

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/go-xorm/xorm/go.sum

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/go-xorm/xorm/statement_args.go

+34-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/go-xorm/xorm/statement_exprparam.go

+6-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)