1
0
mirror of https://github.com/astaxie/beego.git synced 2024-12-22 23:40:50 +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
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

View File

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