aboutsummaryrefslogtreecommitdiff
path: root/internal/sqlutil/connection_manager.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/sqlutil/connection_manager.go')
-rw-r--r--internal/sqlutil/connection_manager.go16
1 files changed, 9 insertions, 7 deletions
diff --git a/internal/sqlutil/connection_manager.go b/internal/sqlutil/connection_manager.go
index 934a2954..4933cfaf 100644
--- a/internal/sqlutil/connection_manager.go
+++ b/internal/sqlutil/connection_manager.go
@@ -29,24 +29,26 @@ type Connections struct {
processContext *process.ProcessContext
}
-func NewConnectionManager(processCtx *process.ProcessContext, globalConfig config.DatabaseOptions) Connections {
- return Connections{
+func NewConnectionManager(processCtx *process.ProcessContext, globalConfig config.DatabaseOptions) *Connections {
+ return &Connections{
globalConfig: globalConfig,
processContext: processCtx,
}
}
func (c *Connections) Connection(dbProperties *config.DatabaseOptions) (*sql.DB, Writer, error) {
- writer := NewDummyWriter()
- if dbProperties.ConnectionString.IsSQLite() {
- writer = NewExclusiveWriter()
- }
var err error
if dbProperties.ConnectionString == "" {
// if no connectionString was provided, try the global one
dbProperties = &c.globalConfig
}
- if dbProperties.ConnectionString != "" || c.db == nil {
+
+ writer := NewDummyWriter()
+ if dbProperties.ConnectionString.IsSQLite() {
+ writer = NewExclusiveWriter()
+ }
+
+ if dbProperties.ConnectionString != "" && c.db == nil {
// Open a new database connection using the supplied config.
c.db, err = Open(dbProperties, writer)
if err != nil {