From 9625ac6a5efb7fbc1489671b71c391466ae275a8 Mon Sep 17 00:00:00 2001 From: Jonathan Bernard Date: Mon, 25 Apr 2022 18:22:34 -0500 Subject: [PATCH] withPool executes provided statement block in a try/finally to ensure the connection is released. --- src/fiber_orm/pool.nim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/fiber_orm/pool.nim b/src/fiber_orm/pool.nim index f5252f4..d7c06f7 100644 --- a/src/fiber_orm/pool.nim +++ b/src/fiber_orm/pool.nim @@ -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)