mirror of
https://github.com/gogf/gf.git
synced 2025-04-05 11:18:50 +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)
|
source, _ = gregex.ReplaceString(`dbname=([\w\.\-]+)+`, "dbname="+config.Name, source)
|
||||||
}
|
}
|
||||||
} else {
|
} 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 != "" {
|
if config.Name != "" {
|
||||||
source = fmt.Sprintf(
|
source = fmt.Sprintf("%s dbname=%s", source, config.Name)
|
||||||
"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,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if config.Namespace != "" {
|
if config.Namespace != "" {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user