diff --git a/main.go b/main.go index 4c5cad11..fa68e52b 100644 --- a/main.go +++ b/main.go @@ -60,10 +60,6 @@ func Open(dialect string, args ...interface{}) (DB, error) { } dbSql, err = sql.Open(driver, source) - if err == nil { - err = db.DB().Ping() // Send a ping to make sure the database connection is alive. - } - case sqlCommon: source = reflect.Indirect(reflect.ValueOf(value)).FieldByName("dsn").String() dbSql = value @@ -80,6 +76,10 @@ func Open(dialect string, args ...interface{}) (DB, error) { db.parent = &db } + if err == nil { + err = db.DB().Ping() // Send a ping to make sure the database connection is alive. + } + return db, err }