Add before_checkout/after_release callbacks for resources in pool (#36)

add auto_release to DB::Connection (default true on each pool checkout).
fixes #35.
This commit is contained in:
Brian J. Cardiff 2017-01-16 16:47:58 -03:00 committed by GitHub
parent e3762eec46
commit 09b8997636
5 changed files with 47 additions and 2 deletions

View file

@ -98,6 +98,22 @@ describe DB::Database do
end
end
it "should not return connection to pool if checkout explicitly" do
DummyDriver::DummyConnection.clear_connections
DB.open "dummy://localhost:1027?initial_pool_size=1&max_pool_size=1&retry_attempts=0" do |db|
the_cnn = uninitialized DB::Connection
db.using_connection do |cnn|
the_cnn = cnn
db.pool.is_available?(cnn).should be_false
3.times do
cnn.exec("stmt1")
db.pool.is_available?(cnn).should be_false
end
end
db.pool.is_available?(the_cnn).should be_true
end
end
describe "prepared_statements connection option" do
it "defaults to true" do
with_dummy "dummy://localhost:1027" do |db|