mirror of
https://gitea.invidious.io/iv-org/shard-crystal-db.git
synced 2024-08-15 00:53:32 +00:00
Release connection when query cannot be built
This was leaking connection when a query could not be build - ie if an invalid column name was used. More info here - https://github.com/crystal-lang/crystal-mysql/issues/40
This commit is contained in:
parent
28c6f3b715
commit
4fe3884898
1 changed files with 6 additions and 1 deletions
|
@ -34,7 +34,12 @@ module DB
|
||||||
clean_connections
|
clean_connections
|
||||||
conn, existing = @db.checkout_some(@connections)
|
conn, existing = @db.checkout_some(@connections)
|
||||||
@connections << WeakRef.new(conn) unless existing
|
@connections << WeakRef.new(conn) unless existing
|
||||||
conn.prepared.build(@query)
|
begin
|
||||||
|
conn.prepared.build(@query)
|
||||||
|
rescue ex
|
||||||
|
conn.release
|
||||||
|
raise ex
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private def clean_connections
|
private def clean_connections
|
||||||
|
|
Loading…
Reference in a new issue