Merge 10c8478254ca94645b136d6df8d1ff8b63678adc into 294eb58fc2d9ff2e493b4b95033614df8fc798ff

This commit is contained in:
pjebs 2016-08-13 13:23:54 +00:00 committed by GitHub
commit efbdcb4574

View File

@ -47,6 +47,7 @@ func Open(dialect string, args ...interface{}) (*DB, error) {
} else { } else {
var source string var source string
var dbSQL sqlCommon var dbSQL sqlCommon
dontPing := false
switch value := args[0].(type) { switch value := args[0].(type) {
case string: case string:
@ -61,6 +62,12 @@ func Open(dialect string, args ...interface{}) (*DB, error) {
case sqlCommon: case sqlCommon:
source = reflect.Indirect(reflect.ValueOf(value)).FieldByName("dsn").String() source = reflect.Indirect(reflect.ValueOf(value)).FieldByName("dsn").String()
dbSQL = value dbSQL = value
if len(args) == 2 {
aBool, correct := args[1].(bool)
if correct == true {
dontPing = aBool
}
}
} }
db = DB{ db = DB{
@ -73,7 +80,7 @@ func Open(dialect string, args ...interface{}) (*DB, error) {
} }
db.parent = &db db.parent = &db
if err == nil { if err == nil && !dontPing {
err = db.DB().Ping() // Send a ping to make sure the database connection is alive. err = db.DB().Ping() // Send a ping to make sure the database connection is alive.
} }
} }