diff --git a/conn.go b/conn.go index 0c4cfbe2..000c0f24 100644 --- a/conn.go +++ b/conn.go @@ -174,6 +174,7 @@ func connect(ctx context.Context, config *ConnConfig) (c *Conn, err error) { if !config.createdByParseConfig { panic("config must be created by ParseConfig") } + originalConfig := config // This isn't really a deep copy. But it is enough to avoid the config.Config.OnNotification mutation from affecting // other connections with the same config. See https://github.com/jackc/pgx/issues/618. @@ -183,7 +184,7 @@ func connect(ctx context.Context, config *ConnConfig) (c *Conn, err error) { } c = &Conn{ - config: config, + config: originalConfig, connInfo: pgtype.NewConnInfo(), logLevel: config.LogLevel, logger: config.Logger, diff --git a/conn_test.go b/conn_test.go index 72022b21..8a52dbcb 100644 --- a/conn_test.go +++ b/conn_test.go @@ -51,7 +51,7 @@ func TestConnect(t *testing.T) { t.Fatalf("Unable to establish connection: %v", err) } - assert.Equal(t, connString, conn.Config().ConnString()) + assert.Equal(t, config, conn.Config()) var currentDB string err = conn.QueryRow(context.Background(), "select current_database()").Scan(¤tDB) diff --git a/go.mod b/go.mod index b5967ad4..3e45c3e0 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,6 @@ require ( github.com/shopspring/decimal v0.0.0-20200227202807-02e2044944cc github.com/sirupsen/logrus v1.4.2 github.com/stretchr/testify v1.5.1 - go.uber.org/multierr v1.5.0 // indirect go.uber.org/zap v1.10.0 golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 gopkg.in/inconshreveable/log15.v2 v2.0.0-20180818164646-67afb5ed74ec