Skip to content

Commit

Permalink
fix: adopt driver-picking logic from dburl 0.16 (#291)
Browse files Browse the repository at this point in the history
  • Loading branch information
burningalchemist authored Aug 21, 2023
1 parent f27aad9 commit 1d12437
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,14 @@ func OpenConnection(ctx context.Context, logContext, dsn string, maxConns, maxId
return nil, err
}

driver := url.Driver
if url.GoDriver != "" {
driver = url.GoDriver
}

// Open the DB handle in a separate goroutine so we can terminate early if the context closes.
go func() {
conn, err = sql.Open(url.Driver, url.DSN)
conn, err = sql.Open(driver, url.DSN)
close(ch)
}()

Expand All @@ -50,7 +55,7 @@ func OpenConnection(ctx context.Context, logContext, dsn string, maxConns, maxId
if len(logContext) > 0 {
logContext = fmt.Sprintf("[%s] ", logContext)
}
klog.Infof("%sDatabase handle successfully opened with '%s' driver", logContext, url.Driver)
klog.Infof("%sDatabase handle successfully opened with '%s' driver", logContext, driver)
}
return conn, nil
}
Expand Down

0 comments on commit 1d12437

Please sign in to comment.