gorm/callbacks/raw.go

15 lines
276 B
Go
Raw Normal View History

2020-02-22 14:41:01 +03:00
package callbacks
2020-02-22 15:57:29 +03:00
import (
"github.com/jinzhu/gorm"
)
2020-02-22 14:41:01 +03:00
func RawExec(db *gorm.DB) {
result, err := db.DB.ExecContext(db.Context, db.Statement.SQL.String(), db.Statement.Vars...)
if err != nil {
db.AddError(err)
2020-02-22 15:57:29 +03:00
} else {
db.RowsAffected, _ = result.RowsAffected()
2020-02-22 14:41:01 +03:00
}
}