MCPcopy
hub / github.com/go-gorm/gorm / BeginTransaction

Function BeginTransaction

callbacks/transaction.go:7–18  ·  view source on GitHub ↗
(db *gorm.DB)

Source from the content-addressed store, hash-verified

5)
6
7func BeginTransaction(db *gorm.DB) {
8 if !db.Config.SkipDefaultTransaction && db.Error == nil {
9 if tx := db.Begin(); tx.Error == nil {
10 db.Statement.ConnPool = tx.Statement.ConnPool
11 db.InstanceSet("gorm:started_transaction", true)
12 } else if tx.Error == gorm.ErrInvalidTransaction {
13 tx.Error = nil
14 } else {
15 db.Error = tx.Error
16 }
17 }
18}
19
20func CommitOrRollbackTransaction(db *gorm.DB) {
21 if !db.Config.SkipDefaultTransaction {

Callers

nothing calls this directly

Calls 2

BeginMethod · 0.80
InstanceSetMethod · 0.80

Tested by

no test coverage detected