Store original config in Conn before updating it.
This commit is contained in:
@@ -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,
|
||||
|
||||
+1
-1
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user