Fixed issue https://github.com/jinzhu/gorm/issues/151 where postgresql connection problems fail silently
This commit is contained in:
parent
82d726bbfd
commit
bb8e0a9d84
7
main.go
7
main.go
@ -59,6 +59,13 @@ func Open(dialect string, args ...interface{}) (DB, error) {
|
||||
driver = "postgres" // FoundationDB speaks a postgres-compatible protocol.
|
||||
}
|
||||
dbSql, err = sql.Open(driver, source)
|
||||
|
||||
// For some reason, postgres does not throw an connection error.
|
||||
// Sending a ping request after the connection is made is a quick workaround for this
|
||||
if driver == "postgres" && err != nil {
|
||||
err = db.DB().Ping()
|
||||
}
|
||||
|
||||
case sqlCommon:
|
||||
source = reflect.Indirect(reflect.ValueOf(value)).FieldByName("dsn").String()
|
||||
dbSql = value
|
||||
|
Loading…
x
Reference in New Issue
Block a user