Make sure to return the connection to the pool in case of an exception preparing a query

This commit is contained in:
Ary Borenszweig 2016-06-29 15:01:26 -03:00
parent 22a5a41534
commit 2fc3f66a00
1 changed files with 7 additions and 1 deletions

View File

@ -30,7 +30,13 @@ module DB
# :nodoc:
def prepare(query)
get_from_pool.prepare(query)
conn = get_from_pool
begin
conn.prepare(query)
rescue ex
return_to_pool(conn)
raise ex
end
end
# :nodoc: