diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2021-11-21 23:41:00 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-21 23:41:00 +0800 |
commit | d710af6669654f27f02b69d7ef1ba563e7d58a90 (patch) | |
tree | 9727f468a570106293dc90beb70035180bbb7e8e /models/project_board.go | |
parent | 0add627182388ac63fd04b94cdf912fb87fd0326 (diff) | |
download | gitea-d710af6669654f27f02b69d7ef1ba563e7d58a90.tar.gz gitea-d710af6669654f27f02b69d7ef1ba563e7d58a90.zip |
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
Diffstat (limited to 'models/project_board.go')
-rw-r--r-- | models/project_board.go | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/models/project_board.go b/models/project_board.go index e6c9f03386..2d422a203b 100644 --- a/models/project_board.go +++ b/models/project_board.go @@ -13,7 +13,6 @@ import ( "code.gitea.io/gitea/modules/timeutil" "xorm.io/builder" - "xorm.io/xorm" ) type ( @@ -69,7 +68,7 @@ func IsProjectBoardTypeValid(p ProjectBoardType) bool { } } -func createBoardsForProjectsType(sess *xorm.Session, project *Project) error { +func createBoardsForProjectsType(sess db.Engine, project *Project) error { var items []string switch project.BoardType { @@ -117,17 +116,17 @@ func NewProjectBoard(board *ProjectBoard) error { // DeleteProjectBoardByID removes all issues references to the project board. func DeleteProjectBoardByID(boardID int64) 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() - if err := deleteProjectBoardByID(sess, boardID); err != nil { + if err := deleteProjectBoardByID(db.GetEngine(ctx), boardID); err != nil { return err } - return sess.Commit() + return committer.Commit() } func deleteProjectBoardByID(e db.Engine, boardID int64) error { |