feat: nil

This commit is contained in:
qqxhb 2023-08-18 19:33:38 +08:00
parent a219acca4b
commit 35d2ba9f08
1 changed files with 4 additions and 2 deletions

View File

@ -374,8 +374,10 @@ func (db *DB) AddError(err error) error {
// DB returns `*sql.DB`
func (db *DB) DB() (*sql.DB, error) {
connPool := db.Statement.ConnPool
connPool := db.ConnPool
if db.Statement != nil && db.Statement.ConnPool != nil {
connPool = db.Statement.ConnPool
}
if tx, ok := connPool.(*sql.Tx); ok && tx != nil {
return (*sql.DB)(reflect.ValueOf(tx).Elem().FieldByName("db").UnsafePointer()), nil
}