Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix IdlePool option #380

Merged
merged 1 commit into from
May 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,9 @@ func (c *Connection) Open() error {
return errors.Wrap(err, "could not open database connection")
}
db.SetMaxOpenConns(details.Pool)
db.SetMaxIdleConns(details.IdlePool)
if details.IdlePool != 0 {
db.SetMaxIdleConns(details.IdlePool)
}
c.Store = &dB{db}

if d, ok := c.Dialect.(afterOpenable); ok {
Expand Down
2 changes: 1 addition & 1 deletion connection_details.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ type ConnectionDetails struct {
URL string
// Defaults to 0 "unlimited". See https://golang.org/pkg/database/sql/#DB.SetMaxOpenConns
Pool int
// Defaults to 0 "unlimited". See https://golang.org/pkg/database/sql/#DB.SetMaxIdleConns
// Defaults to 2. See https://golang.org/pkg/database/sql/#DB.SetMaxIdleConns
IdlePool int
Options map[string]string
// Query string encoded options from URL. Example: "sslmode=disable"
Expand Down