mirror of
https://gitea.invidious.io/iv-org/shard-crystal-db.git
synced 2024-08-15 00:53:32 +00:00
Avoid tracking the connection if the statement failed to be built
This commit is contained in:
parent
9b03aa6535
commit
966b5ac42b
1 changed files with 3 additions and 2 deletions
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue