Param overriding doesn't work for some fields
cat1s-smile opened this issue · comments
Describe the bug
I'm trying to create Config by parsing empty conn string and getting auth error
failed to connect to 'host=localhost user=test database=test_namespace': failed SASL auth (FATAL: password authentication failed for user "test" (SQLSTATE 28P01))
To Reproduce
Steps to reproduce the behavior:
Create Config by parsing empty conn string, fill required params and try to connect to DB
If possible, please provide runnable example such as:
package main
import (
"context"
"github.com/jackc/pgx/v5"
"github.com/jackc/pgx/v5/pgxpool"
)
func main() {
cfg, _ := pgxpool.ParseConfig("")
cfg.ConnConfig.Host = "localhost"
cfg.ConnConfig.Port = 5444
cfg.ConnConfig.Database = "test_namespace"
cfg.ConnConfig.User = "test"
cfg.ConnConfig.Password = "test"
pgp, err := pgxpool.NewWithConfig(context.Background(), cfg)
if err != nil {
log.Fatal(err)
}
rs, err := pgp.Query(context.Background(), "select 1")
fmt.Println(err)
fmt.Println(rs.Next())
fmt.Println(rs.Values())
}
However if I change exactly one line with config parsing
cfg, _ := pgxpool.ParseConfig("port=5444 database=test_namespace")
everything works properly
Expected behavior
successful run after soecifying all the params as cfg.ConnConfig.ParamName = ...
Actual behavior
failed to connect to 'host=localhost user=test database=test_namespace': failed SASL auth (FATAL: password authentication failed for user "test" (SQLSTATE 28P01))
Version
- Go: go1.22.1 windows/amd64
- PostgreSQL: PostgreSQL 12.2 (Debian 12.2-1.pgdg100+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 8.3.0-6) 8.3.0, 64-bit
- pgx: v5.5.5
Additional context
Add any other context about the problem here.