Remove NewSession method from db.Engine interface (#17577)

* Remove NewSession method from db.Engine interface

* Fix bug

* Some improvements

* Fix bug

* Fix test

* Use XXXBean instead of XXXExample
This commit is contained in:
Lunny Xiao 2021-11-21 23:41:00 +08:00 committed by GitHub
parent 0add627182
commit d710af6669
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
44 changed files with 600 additions and 620 deletions

View file

@ -185,11 +185,12 @@ func addUpdateIssueProject(ctx context.Context, issue *Issue, doer *User, newPro
// MoveIssueAcrossProjectBoards move a card from one board to another
func MoveIssueAcrossProjectBoards(issue *Issue, board *ProjectBoard) error {
sess := db.NewSession(db.DefaultContext)
defer sess.Close()
if err := sess.Begin(); err != nil {
ctx, committer, err := db.TxContext()
if err != nil {
return err
}
defer committer.Close()
sess := db.GetEngine(ctx)
var pis ProjectIssue
has, err := sess.Where("issue_id=?", issue.ID).Get(&pis)
@ -206,7 +207,7 @@ func MoveIssueAcrossProjectBoards(issue *Issue, board *ProjectBoard) error {
return err
}
return sess.Commit()
return committer.Commit()
}
func (pb *ProjectBoard) removeIssues(e db.Engine) error {