Release connection when unprepared statements can't be built

Add specs
Fix typo in docs
This commit is contained in:
Brian J. Cardiff 2017-09-07 19:21:36 -03:00
parent 4fe3884898
commit 9b03aa6535
4 changed files with 31 additions and 2 deletions

View file

@ -29,7 +29,7 @@ module DB
end
# builds a statement over a real connection
# the conneciton is registered in `@connections`
# the connection is registered in `@connections`
private def build_statement
clean_connections
conn, existing = @db.checkout_some(@connections)

View file

@ -15,7 +15,13 @@ module DB
# builds a statement over a real connection
private def build_statement
@db.pool.checkout.unprepared.build(@query)
conn = @db.pool.checkout
begin
conn.unprepared.build(@query)
rescue ex
conn.release
raise ex
end
end
end
end