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/issue_label.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/issue_label.go')
-rw-r--r-- | models/issue_label.go | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/models/issue_label.go b/models/issue_label.go index 492e298600..2858b12dde 100644 --- a/models/issue_label.go +++ b/models/issue_label.go @@ -297,11 +297,13 @@ func DeleteLabel(id, labelID int64) error { return err } - 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) if label.BelongsToOrg() && label.OrgID != id { return nil @@ -323,7 +325,7 @@ func DeleteLabel(id, labelID int64) error { return err } - return sess.Commit() + return committer.Commit() } // getLabelByID returns a label by label id |