forked from mirror/gorm
Merge pull request #1423 from emil2k/open-tx
Allow open to take transaction.
This commit is contained in:
commit
33aa952d07
10
main.go
10
main.go
|
@ -71,11 +71,13 @@ func Open(dialect string, args ...interface{}) (db *DB, err error) {
|
||||||
dialect: newDialect(dialect, dbSQL),
|
dialect: newDialect(dialect, dbSQL),
|
||||||
}
|
}
|
||||||
db.parent = db
|
db.parent = db
|
||||||
|
if err != nil {
|
||||||
if err == nil {
|
return
|
||||||
|
}
|
||||||
// Send a ping to make sure the database connection is alive.
|
// Send a ping to make sure the database connection is alive.
|
||||||
if err = db.DB().Ping(); err != nil {
|
if d, ok := dbSQL.(*sql.DB); ok {
|
||||||
db.DB().Close()
|
if err = d.Ping(); err != nil {
|
||||||
|
d.Close()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in New Issue