feat: unsafe pointer

This commit is contained in:
qqxhb 2023-08-29 16:57:31 +08:00
parent e57e5d8884
commit cd9a163fd8
1 changed files with 2 additions and 1 deletions

View File

@ -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 {