Skip to content

Commit

Permalink
fix(inputs.postgresql_extensible): Restore default db name (influxdat…
Browse files Browse the repository at this point in the history
  • Loading branch information
powersj authored Oct 13, 2023
1 parent 309c195 commit 7adcc70
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
10 changes: 1 addition & 9 deletions plugins/inputs/postgresql/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
{
Expand Down

0 comments on commit 7adcc70

Please sign in to comment.