rename ConnStr -> ConnString

pull/751/head
georgysavva 2020-05-16 19:24:57 +03:00
parent 7c73e608ff
commit 33cbec368f
4 changed files with 12 additions and 12 deletions

View File

@ -30,7 +30,7 @@ type ConnConfig struct {
LogLevel LogLevel
// Original connection string that was parsed into config.
ConnStr string
ConnString string
// BuildStatementCache creates the stmtcache.Cache implementation for connections created with this config. Set
// to nil to disable automatic prepared statements.
@ -160,7 +160,7 @@ func ParseConfig(connString string) (*ConnConfig, error) {
createdByParseConfig: true,
LogLevel: LogLevelInfo,
BuildStatementCache: buildStatementCache,
ConnStr: connString,
ConnString: connString,
}
return connConfig, nil
@ -422,8 +422,8 @@ func (c *Conn) StatementCache() stmtcache.Cache { return c.stmtcache }
// ConnInfo returns the connection info used for this connection.
func (c *Conn) ConnInfo() *pgtype.ConnInfo { return c.connInfo }
// ConnStr returns the connection string that was used to establish this connection.
func (c *Conn) ConnStr() string { return c.config.ConnStr }
// ConnString returns the connection string that was used to establish this connection.
func (c *Conn) ConnString() string { return c.config.ConnString }
// Exec executes sql. sql can be either a prepared statement name or an SQL string. arguments should be referenced
// positionally from the sql string as $1, $2, etc.

View File

@ -28,7 +28,7 @@ func TestCrateDBConnect(t *testing.T) {
require.Nil(t, err)
defer closeConn(t, conn)
assert.Equal(t, connString, conn.ConnStr())
assert.Equal(t, connString, conn.ConnString())
var result int
err = conn.QueryRow(context.Background(), "select 1 +1").Scan(&result)
@ -51,7 +51,7 @@ func TestConnect(t *testing.T) {
t.Fatalf("Unable to establish connection: %v", err)
}
assert.Equal(t, connStr, conn.ConnStr())
assert.Equal(t, connStr, conn.ConnString())
var currentDB string
err = conn.QueryRow(context.Background(), "select current_database()").Scan(&currentDB)
@ -113,7 +113,7 @@ func TestConfigContainsConnStr(t *testing.T) {
connStr := os.Getenv("PGX_TEST_DATABASE")
config, err := pgx.ParseConfig(connStr)
require.NoError(t, err)
assert.Equal(t, connStr, config.ConnStr)
assert.Equal(t, connStr, config.ConnString)
}
func TestParseConfigExtractsStatementCacheOptions(t *testing.T) {

View File

@ -69,7 +69,7 @@ func (cr *connResource) getPoolRows(c *Conn, r pgx.Rows) *poolRows {
type Pool struct {
p *puddle.Pool
connStr string
connString string
afterConnect func(context.Context, *pgx.Conn) error
beforeAcquire func(context.Context, *pgx.Conn) bool
afterRelease func(*pgx.Conn) bool
@ -142,7 +142,7 @@ func ConnectConfig(ctx context.Context, config *Config) (*Pool, error) {
}
p := &Pool{
connStr: config.ConnConfig.ConnStr,
connString: config.ConnConfig.ConnString,
afterConnect: config.AfterConnect,
beforeAcquire: config.BeforeAcquire,
afterRelease: config.AfterRelease,
@ -371,8 +371,8 @@ func (p *Pool) AcquireAllIdle(ctx context.Context) []*Conn {
return conns
}
// ConnStr returns the connection string that was used to initialize this pool.
func (p *Pool) ConnStr() string { return p.connStr }
// ConnString returns the connection string that was used to initialize this pool.
func (p *Pool) ConnString() string { return p.connString }
func (p *Pool) Stat() *Stat {
return &Stat{s: p.p.Stat()}

View File

@ -17,7 +17,7 @@ func TestConnect(t *testing.T) {
connStr := os.Getenv("PGX_TEST_DATABASE")
pool, err := pgxpool.Connect(context.Background(), connStr)
require.NoError(t, err)
assert.Equal(t, connStr, pool.ConnStr())
assert.Equal(t, connStr, pool.ConnString())
pool.Close()
}