mirror of
https://github.com/jackc/pgx.git
synced 2025-05-31 11:42:24 +00:00
rename ConnStr -> ConnString
This commit is contained in:
parent
7c73e608ff
commit
33cbec368f
8
conn.go
8
conn.go
@ -30,7 +30,7 @@ type ConnConfig struct {
|
|||||||
LogLevel LogLevel
|
LogLevel LogLevel
|
||||||
|
|
||||||
// Original connection string that was parsed into config.
|
// 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
|
// BuildStatementCache creates the stmtcache.Cache implementation for connections created with this config. Set
|
||||||
// to nil to disable automatic prepared statements.
|
// to nil to disable automatic prepared statements.
|
||||||
@ -160,7 +160,7 @@ func ParseConfig(connString string) (*ConnConfig, error) {
|
|||||||
createdByParseConfig: true,
|
createdByParseConfig: true,
|
||||||
LogLevel: LogLevelInfo,
|
LogLevel: LogLevelInfo,
|
||||||
BuildStatementCache: buildStatementCache,
|
BuildStatementCache: buildStatementCache,
|
||||||
ConnStr: connString,
|
ConnString: connString,
|
||||||
}
|
}
|
||||||
|
|
||||||
return connConfig, nil
|
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.
|
// ConnInfo returns the connection info used for this connection.
|
||||||
func (c *Conn) ConnInfo() *pgtype.ConnInfo { return c.connInfo }
|
func (c *Conn) ConnInfo() *pgtype.ConnInfo { return c.connInfo }
|
||||||
|
|
||||||
// ConnStr returns the connection string that was used to establish this connection.
|
// ConnString returns the connection string that was used to establish this connection.
|
||||||
func (c *Conn) ConnStr() string { return c.config.ConnStr }
|
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
|
// 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.
|
// positionally from the sql string as $1, $2, etc.
|
||||||
|
@ -28,7 +28,7 @@ func TestCrateDBConnect(t *testing.T) {
|
|||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
defer closeConn(t, conn)
|
defer closeConn(t, conn)
|
||||||
|
|
||||||
assert.Equal(t, connString, conn.ConnStr())
|
assert.Equal(t, connString, conn.ConnString())
|
||||||
|
|
||||||
var result int
|
var result int
|
||||||
err = conn.QueryRow(context.Background(), "select 1 +1").Scan(&result)
|
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)
|
t.Fatalf("Unable to establish connection: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
assert.Equal(t, connStr, conn.ConnStr())
|
assert.Equal(t, connStr, conn.ConnString())
|
||||||
|
|
||||||
var currentDB string
|
var currentDB string
|
||||||
err = conn.QueryRow(context.Background(), "select current_database()").Scan(¤tDB)
|
err = conn.QueryRow(context.Background(), "select current_database()").Scan(¤tDB)
|
||||||
@ -113,7 +113,7 @@ func TestConfigContainsConnStr(t *testing.T) {
|
|||||||
connStr := os.Getenv("PGX_TEST_DATABASE")
|
connStr := os.Getenv("PGX_TEST_DATABASE")
|
||||||
config, err := pgx.ParseConfig(connStr)
|
config, err := pgx.ParseConfig(connStr)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
assert.Equal(t, connStr, config.ConnStr)
|
assert.Equal(t, connStr, config.ConnString)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestParseConfigExtractsStatementCacheOptions(t *testing.T) {
|
func TestParseConfigExtractsStatementCacheOptions(t *testing.T) {
|
||||||
|
@ -69,7 +69,7 @@ func (cr *connResource) getPoolRows(c *Conn, r pgx.Rows) *poolRows {
|
|||||||
|
|
||||||
type Pool struct {
|
type Pool struct {
|
||||||
p *puddle.Pool
|
p *puddle.Pool
|
||||||
connStr string
|
connString string
|
||||||
afterConnect func(context.Context, *pgx.Conn) error
|
afterConnect func(context.Context, *pgx.Conn) error
|
||||||
beforeAcquire func(context.Context, *pgx.Conn) bool
|
beforeAcquire func(context.Context, *pgx.Conn) bool
|
||||||
afterRelease func(*pgx.Conn) bool
|
afterRelease func(*pgx.Conn) bool
|
||||||
@ -142,7 +142,7 @@ func ConnectConfig(ctx context.Context, config *Config) (*Pool, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
p := &Pool{
|
p := &Pool{
|
||||||
connStr: config.ConnConfig.ConnStr,
|
connString: config.ConnConfig.ConnString,
|
||||||
afterConnect: config.AfterConnect,
|
afterConnect: config.AfterConnect,
|
||||||
beforeAcquire: config.BeforeAcquire,
|
beforeAcquire: config.BeforeAcquire,
|
||||||
afterRelease: config.AfterRelease,
|
afterRelease: config.AfterRelease,
|
||||||
@ -371,8 +371,8 @@ func (p *Pool) AcquireAllIdle(ctx context.Context) []*Conn {
|
|||||||
return conns
|
return conns
|
||||||
}
|
}
|
||||||
|
|
||||||
// ConnStr returns the connection string that was used to initialize this pool.
|
// ConnString returns the connection string that was used to initialize this pool.
|
||||||
func (p *Pool) ConnStr() string { return p.connStr }
|
func (p *Pool) ConnString() string { return p.connString }
|
||||||
|
|
||||||
func (p *Pool) Stat() *Stat {
|
func (p *Pool) Stat() *Stat {
|
||||||
return &Stat{s: p.p.Stat()}
|
return &Stat{s: p.p.Stat()}
|
||||||
|
@ -17,7 +17,7 @@ func TestConnect(t *testing.T) {
|
|||||||
connStr := os.Getenv("PGX_TEST_DATABASE")
|
connStr := os.Getenv("PGX_TEST_DATABASE")
|
||||||
pool, err := pgxpool.Connect(context.Background(), connStr)
|
pool, err := pgxpool.Connect(context.Background(), connStr)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
assert.Equal(t, connStr, pool.ConnStr())
|
assert.Equal(t, connStr, pool.ConnString())
|
||||||
pool.Close()
|
pool.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user