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
Suggestion: txdb.Close(name string) to close txdb.txDriver.db #28
Comments
Hi, the whole purpose of txdb is to improve performance and isolation for a test database. if you are recreating database on every test, it does not seem to be worth it. Postgres specifically, supports table related operations within transaction, so each of your test could create tables and have them rolled back after test is done. But I do not see an issue in adding this method. you could open the pull request. but maybe instead of Reset it could be called, Close |
@l3pp4rd My use case is to create a temporary database in I could definitely submit a pull request for this, with under the name of |
yes, I think the pull request can be accepted it makes sense |
I have now revised my opinion: we should not require the developer to call |
I’ve run into a small problem with
txdb
because it automatically opens a new connection here:go-txdb/db.go
Lines 122 to 128 in 6ca798a
However, there is no way to call
txdb.txDriver.db.Close()
, which would be nice because I am spawning temporary test databases that are dropped after the tests are run. Unfortunately, because PostgreSQL doesn’t let you destroy an active database, having something hold thesql.DB
connection makes the following SQL fail:My suggestion is to create a new function called
txdb.Reset
:This would also require changes to
txdb.Register
:Sorry I have not tested or documented this code.
The text was updated successfully, but these errors were encountered: