withPool executes provided statement block in a try/finally to ensure the connection is released.

This commit is contained in:
Jonathan Bernard 2022-04-25 18:22:34 -05:00
parent d4540a1de7
commit 9625ac6a5e

View File

@ -93,5 +93,5 @@ proc release*(pool: DbConnPool, connId: int): void =
template withConn*(pool: DbConnPool, stmt: untyped): untyped =
let (connId, conn {.inject.}) = take(pool)
stmt
release(pool, connId)
try: stmt
finally: release(pool, connId)