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

ConnectContext should close the db when PingContext returns an error #910

Open
chad-wheeler-sp opened this issue Feb 7, 2024 · 0 comments

Comments

@chad-wheeler-sp
Copy link

ConnectContext() should close the db when PingContext() returns an error.

The Open() function does not test the validity of the actual connection....auth or host....but does create a routine to handle opening connection through the sql.Open()->sql.OpenDB() statement. When PingContext() return an error due to bad auth or host connectivity then the wrapped db with the open routine is returned along with the error. It is not obvious that the db returned from the ConnectContext should be closed when an error is returned.

The Connect() function is executing the db.Close() so why doesn't the ConnectContext()?

Solution should be just as Connect() in that the db.Close() is executed and nil returned for the db.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant