(db *gorm.DB)
| 5 | ) |
| 6 | |
| 7 | func 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 | |
| 20 | func CommitOrRollbackTransaction(db *gorm.DB) { |
| 21 | if !db.Config.SkipDefaultTransaction { |
nothing calls this directly
no test coverage detected