fix(inputs.postgresql_extensible): Restore default db name (#14010)
This commit is contained in:
parent
309c195e03
commit
7adcc701f9
|
|
@ -177,16 +177,8 @@ func (p *Service) SanitizedAddress() (sanitizedAddress string, err error) {
|
||||||
// GetConnectDatabase utility function for getting the database to which the connection was made
|
// GetConnectDatabase utility function for getting the database to which the connection was made
|
||||||
// If the user set the output address use that before parsing anything else.
|
// If the user set the output address use that before parsing anything else.
|
||||||
func (p *Service) GetConnectDatabase(connectionString string) (string, error) {
|
func (p *Service) GetConnectDatabase(connectionString string) (string, error) {
|
||||||
if p.OutputAddress != "" {
|
|
||||||
return p.OutputAddress, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
connConfig, err := pgx.ParseConfig(connectionString)
|
connConfig, err := pgx.ParseConfig(connectionString)
|
||||||
if err != nil {
|
if err == nil && len(connConfig.Database) != 0 {
|
||||||
return "", fmt.Errorf("connection string parsing failed: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(connConfig.Database) != 0 {
|
|
||||||
return connConfig.Database, nil
|
return connConfig.Database, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -311,14 +311,14 @@ func TestAccRow(t *testing.T) {
|
||||||
fields: fakeRow{
|
fields: fakeRow{
|
||||||
fields: []interface{}{1, "gato"},
|
fields: []interface{}{1, "gato"},
|
||||||
},
|
},
|
||||||
dbName: "server",
|
dbName: "postgres",
|
||||||
server: "server",
|
server: "server",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
fields: fakeRow{
|
fields: fakeRow{
|
||||||
fields: []interface{}{nil, "gato"},
|
fields: []interface{}{nil, "gato"},
|
||||||
},
|
},
|
||||||
dbName: "server",
|
dbName: "postgres",
|
||||||
server: "server",
|
server: "server",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue