mirror of
https://github.com/gogf/gf.git
synced 2025-04-05 03:05:05 +08:00
fix(contrib/drivers/pgsql): connection fails when postgres database password is empty (#3900)
This commit is contained in:
parent
e7cc2c3d9c
commit
f4db846633
@ -34,16 +34,12 @@ func (d *Driver) Open(config *gdb.ConfigNode) (db *sql.DB, err error) {
|
||||
source, _ = gregex.ReplaceString(`dbname=([\w\.\-]+)+`, "dbname="+config.Name, source)
|
||||
}
|
||||
} else {
|
||||
source = fmt.Sprintf(
|
||||
"user=%s password='%s' host=%s port=%s sslmode=disable",
|
||||
config.User, config.Pass, config.Host, config.Port)
|
||||
|
||||
if config.Name != "" {
|
||||
source = fmt.Sprintf(
|
||||
"user=%s password=%s host=%s port=%s dbname=%s sslmode=disable",
|
||||
config.User, config.Pass, config.Host, config.Port, config.Name,
|
||||
)
|
||||
} else {
|
||||
source = fmt.Sprintf(
|
||||
"user=%s password=%s host=%s port=%s sslmode=disable",
|
||||
config.User, config.Pass, config.Host, config.Port,
|
||||
)
|
||||
source = fmt.Sprintf("%s dbname=%s", source, config.Name)
|
||||
}
|
||||
|
||||
if config.Namespace != "" {
|
||||
|
Loading…
x
Reference in New Issue
Block a user