mirror of
https://gitea.invidious.io/iv-org/shard-crystal-db.git
synced 2024-08-15 00:53:32 +00:00
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:
parent
e3762eec46
commit
09b8997636
5 changed files with 47 additions and 2 deletions
|
@ -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|
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue