Avoid tracking the connection if the statement failed to be built

This commit is contained in:
Brian J. Cardiff 2017-09-07 19:29:32 -03:00
parent 9b03aa6535
commit 966b5ac42b

View file

@ -33,13 +33,14 @@ module DB
private def build_statement
clean_connections
conn, existing = @db.checkout_some(@connections)
@connections << WeakRef.new(conn) unless existing
begin
conn.prepared.build(@query)
stmt = conn.prepared.build(@query)
rescue ex
conn.release
raise ex
end
@connections << WeakRef.new(conn) unless existing
stmt
end
private def clean_connections