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

Method RollbackTo

finisher_api.go:760–781  ·  view source on GitHub ↗
(name string)

Source from the content-addressed store, hash-verified

758}
759
760func (db *DB) RollbackTo(name string) *DB {
761 if savePointer, ok := db.Dialector.(SavePointerDialectorInterface); ok {
762 // close prepared statement, because RollbackTo not support prepared statement.
763 // e.g. mysql8.0 doc: https://dev.mysql.com/doc/refman/8.0/en/sql-prepared-statements.html
764 var (
765 preparedStmtTx *PreparedStmtTX
766 isPreparedStmtTx bool
767 )
768 // close prepared statement, because SavePoint not support prepared statement.
769 if preparedStmtTx, isPreparedStmtTx = db.Statement.ConnPool.(*PreparedStmtTX); isPreparedStmtTx {
770 db.Statement.ConnPool = preparedStmtTx.Tx
771 }
772 db.AddError(savePointer.RollbackTo(db, name))
773 // restore prepared statement
774 if isPreparedStmtTx {
775 db.Statement.ConnPool = preparedStmtTx
776 }
777 } else {
778 db.AddError(ErrUnsupportedDriver)
779 }
780 return db
781}
782
783// Exec executes raw sql
784func (db *DB) Exec(sql string, values ...interface{}) (tx *DB) {

Callers 1

TransactionMethod · 0.95

Calls 2

AddErrorMethod · 0.95
RollbackToMethod · 0.65

Tested by

no test coverage detected