mirror of https://github.com/go-gorm/gorm.git
feat: unsafe pointer
This commit is contained in:
parent
e57e5d8884
commit
cd9a163fd8
3
gorm.go
3
gorm.go
|
@ -8,6 +8,7 @@ import (
|
|||
"sort"
|
||||
"sync"
|
||||
"time"
|
||||
"unsafe"
|
||||
|
||||
"gorm.io/gorm/clause"
|
||||
"gorm.io/gorm/logger"
|
||||
|
@ -379,7 +380,7 @@ func (db *DB) DB() (*sql.DB, error) {
|
|||
connPool = db.Statement.ConnPool
|
||||
}
|
||||
if tx, ok := connPool.(*sql.Tx); ok && tx != nil {
|
||||
return (*sql.DB)(reflect.ValueOf(tx).Elem().FieldByName("db").UnsafePointer()), nil
|
||||
return (*sql.DB)(unsafe.Pointer(reflect.ValueOf(tx).Elem().FieldByName("db").Addr().Pointer())), nil
|
||||
}
|
||||
|
||||
if dbConnector, ok := connPool.(GetDBConnector); ok && dbConnector != nil {
|
||||
|
|
Loading…
Reference in New Issue