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 private def build_statement
clean_connections clean_connections
conn, existing = @db.checkout_some(@connections) conn, existing = @db.checkout_some(@connections)
@connections << WeakRef.new(conn) unless existing
begin begin
conn.prepared.build(@query) stmt = conn.prepared.build(@query)
rescue ex rescue ex
conn.release conn.release
raise ex raise ex
end end
@connections << WeakRef.new(conn) unless existing
stmt
end end
private def clean_connections private def clean_connections