diff --git a/orm/orm.go b/orm/orm.go index b7296ab9..fc3cd400 100644 --- a/orm/orm.go +++ b/orm/orm.go @@ -523,8 +523,13 @@ func (o *orm) Driver() Driver { } // return sql.DBStats for current database -func (o *orm) DBStats() sql.DBStats { - return o.alias.DB.Stats() +func (o *orm) DBStats() *sql.DBStats { + if o.alias != nil && o.alias.DB != nil { + stats := o.alias.DB.Stats() + return &stats + } + + return nil } // NewOrm create new orm diff --git a/orm/types.go b/orm/types.go index 4c67c7a6..6c6443c7 100644 --- a/orm/types.go +++ b/orm/types.go @@ -128,7 +128,7 @@ type Ormer interface { // // update user testing's name to slene Raw(query string, args ...interface{}) RawSeter Driver() Driver - DBStats() sql.DBStats + DBStats() *sql.DBStats } // Inserter insert prepared statement