-
-
Notifications
You must be signed in to change notification settings - Fork 956
Password in Config is ignored #1301
Copy link
Copy link
Closed
Description
Good day and thanks for this great package.
I've just encountered an issue with the connection config.
In version v1.11.2 if you assign a password via the Config fields, it is ignored.
Simplified example with error handling removed:
cfg, _ := pq.NewConfig("")
cfg.User = "myuser"
cfg.Password = "secret"
connCfg, _ := pq.NewConnectorConfig(cfg)
db := sql.OpenDB(connCfg)
err := db.Ping()
if err != nil {
// we are now here because the password is not assigned
}Digging a bit deeper, in conn.go, func DialOpen(...):
cn.cfg.Password = pgpass.PasswordFromPgpass(cn.cfg.Passfile, cn.cfg.User, cn.cfg.Password,
cn.cfg.Host, strconv.Itoa(int(cn.cfg.Port)), cn.cfg.Database, cn.cfg.isset("password"))cn.cfg.isset("password") <-- this is false
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels