1
0
mirror of https://github.com/astaxie/beego.git synced 2024-11-22 22:40:55 +00:00

Nil check

This commit is contained in:
Bharat Patel 2019-01-18 16:51:40 -08:00
parent 2ae480556d
commit f508f8d959
2 changed files with 8 additions and 3 deletions

View File

@ -523,8 +523,13 @@ func (o *orm) Driver() Driver {
} }
// return sql.DBStats for current database // return sql.DBStats for current database
func (o *orm) DBStats() sql.DBStats { func (o *orm) DBStats() *sql.DBStats {
return o.alias.DB.Stats() if o.alias != nil && o.alias.DB != nil {
stats := o.alias.DB.Stats()
return &stats
}
return nil
} }
// NewOrm create new orm // NewOrm create new orm

View File

@ -128,7 +128,7 @@ type Ormer interface {
// // update user testing's name to slene // // update user testing's name to slene
Raw(query string, args ...interface{}) RawSeter Raw(query string, args ...interface{}) RawSeter
Driver() Driver Driver() Driver
DBStats() sql.DBStats DBStats() *sql.DBStats
} }
// Inserter insert prepared statement // Inserter insert prepared statement