fix(inputs.postgresql_extensible): Restore default db name (#14010)

This commit is contained in:
Joshua Powers 2023-10-13 06:17:02 -06:00 committed by GitHub
parent 309c195e03
commit 7adcc701f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 11 deletions

View File

@ -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
// If the user set the output address use that before parsing anything else.
func (p *Service) GetConnectDatabase(connectionString string) (string, error) {
if p.OutputAddress != "" {
return p.OutputAddress, nil
}
connConfig, err := pgx.ParseConfig(connectionString)
if err != nil {
return "", fmt.Errorf("connection string parsing failed: %w", err)
}
if len(connConfig.Database) != 0 {
if err == nil && len(connConfig.Database) != 0 {
return connConfig.Database, nil
}

View File

@ -311,14 +311,14 @@ func TestAccRow(t *testing.T) {
fields: fakeRow{
fields: []interface{}{1, "gato"},
},
dbName: "server",
dbName: "postgres",
server: "server",
},
{
fields: fakeRow{
fields: []interface{}{nil, "gato"},
},
dbName: "server",
dbName: "postgres",
server: "server",
},
{