mirror of https://github.com/go-gorm/gorm.git
feat: nil
This commit is contained in:
parent
a219acca4b
commit
35d2ba9f08
6
gorm.go
6
gorm.go
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue