Skip to content

Commit 492b642

Browse files
authored
#491 Dedupliate Database URLs (#493)
* #491 Savepoint * #491 Prepare for versioned release * #491 Prepare for versioned release
1 parent c8b0e51 commit 492b642

File tree

3 files changed

+26
-8
lines changed

3 files changed

+26
-8
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ and this project adheres to [Semantic Versioning].
99

1010
-
1111

12+
## [0.8.1] - 2025-11-25
13+
14+
### Added in 0.8.1
15+
16+
- Deduplicate database URLs
17+
1218
## [0.8.0] - 2025-11-18
1319

1420
### Added in 0.8.0

cmd/root.go

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"context"
77
"fmt"
88
"os"
9+
"slices"
910
"strings"
1011

1112
"github.com/senzing-garage/go-cmdhelping/cmdhelper"
@@ -165,32 +166,43 @@ func Version() string {
165166

166167
// Get a slice of database URL strings.
167168
func getDatabaseURLs(ctx context.Context, senzingSettings string) ([]string, error) {
168-
var err error
169+
var (
170+
err error
171+
result []string
172+
)
169173

170-
result := []string{}
174+
candidateDatabaseURLs := []string{}
171175

172176
databaseURL := viper.GetString(option.DatabaseURL.Arg)
173177
if len(databaseURL) > 0 {
174-
result = append(result, databaseURL)
178+
candidateDatabaseURLs = append(candidateDatabaseURLs, databaseURL)
175179
}
176180

177-
if len(result) == 0 {
181+
if len(candidateDatabaseURLs) == 0 {
178182
settingsParser, err := settingsparser.New(senzingSettings)
179183
if err != nil {
180-
return result, wraperror.Errorf(err, "getDatabaseURLs")
184+
return candidateDatabaseURLs, wraperror.Errorf(err, "getDatabaseURLs")
181185
}
182186

183187
databaseURIs, err := settingsParser.GetDatabaseURIs(ctx)
184188
if err != nil {
185-
return result, wraperror.Errorf(err, "GetDatabaseURIs")
189+
return candidateDatabaseURLs, wraperror.Errorf(err, "GetDatabaseURIs")
186190
}
187191

188192
for _, databaseURI := range databaseURIs {
189193
databaseURL, err := helpersettings.BuildSenzingDatabaseURL(databaseURI)
190194
if err != nil {
191-
return result, wraperror.Errorf(err, "BuildSenzingDatabaseURL: %s", databaseURI)
195+
return candidateDatabaseURLs, wraperror.Errorf(err, "BuildSenzingDatabaseURL: %s", databaseURI)
192196
}
193197

198+
candidateDatabaseURLs = append(candidateDatabaseURLs, databaseURL)
199+
}
200+
}
201+
202+
// Delete duplicates.
203+
204+
for _, databaseURL := range candidateDatabaseURLs {
205+
if !slices.Contains(result, databaseURL) {
194206
result = append(result, databaseURL)
195207
}
196208
}

senzingschema/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ type SenzingSchema interface {
2727
const ComponentID = 6503
2828

2929
// Log message prefix.
30-
const Prefix = "init-database.senzingconfig."
30+
const Prefix = "init-database.senzingschema."
3131

3232
const (
3333
OptionCallerSkip4 = 4

0 commit comments

Comments
 (0)