mirror of https://github.com/go-gorm/gorm.git
fix: avoid coroutine leaks when the dialecter initialization fails. (#6249)
Co-authored-by: Kevin Lin <kevin.lin@shopee.com>
This commit is contained in:
parent
ac20d9e222
commit
32fc201554
6
gorm.go
6
gorm.go
|
@ -179,6 +179,12 @@ func Open(dialector Dialector, opts ...Option) (db *DB, err error) {
|
||||||
|
|
||||||
if config.Dialector != nil {
|
if config.Dialector != nil {
|
||||||
err = config.Dialector.Initialize(db)
|
err = config.Dialector.Initialize(db)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
if db, err := db.DB(); err == nil {
|
||||||
|
_ = db.Close()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
preparedStmt := &PreparedStmtDB{
|
preparedStmt := &PreparedStmtDB{
|
||||||
|
|
Loading…
Reference in New Issue