func (db *gormDB) beginTransaction() (Transaction, error) { log.Debug("gorm#Begin") txn := &gormTxn{} txn.Dbm = db.Dbm.Begin() if err := txn.Dbm.Error; err != nil { log.Error("Failed to begin-transaction %v", err) return nil, err } return txn, nil }
func (txn *sqlxTxn) Commit() error { if txn.Tx == nil { return nil } log.Debug("sqlx#Commit") if err := txn.Tx.Commit(); err != nil { log.Error("Failed to commit-transaction %v", err) return err } txn.Dbm = nil return nil }
/************************** gormTxn functions **************************/ func (txn *gormTxn) Commit() error { if txn.Dbm == nil { return nil } log.Debug("gorm#Commit") if err := txn.Dbm.Commit().Error; err != nil { log.Error("Failed to commit-transaction %v", err) return err } txn.Dbm = nil return nil }
func (db *sqlxDB) beginTransaction() (Transaction, error) { log.Debug("sqlx#Begin") var err error tx, err := db.Dbm.Beginx() if err != nil { log.Error("Failed to begin-transaction %v", err) return nil, err } txn := &sqlxTxn{} txn.Dbm = db.Dbm txn.Tx = tx return txn, nil }