(name string)
| 758 | } |
| 759 | |
| 760 | func (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 |
| 784 | func (db *DB) Exec(sql string, values ...interface{}) (tx *DB) { |
no test coverage detected