mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-05-19 08:20:13 +00:00
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:
parent
0add627182
commit
d710af6669
44 changed files with 600 additions and 620 deletions
|
@ -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(db.GetEngine(ctx), boardID); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := deleteProjectBoardByID(sess, boardID); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return sess.Commit()
|
||||
return committer.Commit()
|
||||
}
|
||||
|
||||
func deleteProjectBoardByID(e db.Engine, boardID int64) error {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue