diff --git a/client.ts b/client.ts index 7635c6a..d254188 100644 --- a/client.ts +++ b/client.ts @@ -515,4 +515,8 @@ export class PoolClient extends QueryClient { // Cleanup all session related metadata this.resetSessionMetadata(); } + + [Symbol.dispose]() { + this.release(); + } } diff --git a/query/array_parser.ts b/query/array_parser.ts index b7983b4..60e27a2 100644 --- a/query/array_parser.ts +++ b/query/array_parser.ts @@ -20,7 +20,7 @@ export function parseArray( source: string, transform: Transformer, separator: AllowedSeparators = ",", -) { +): ArrayResult { return new ArrayParser(source, transform, separator).parse(); } diff --git a/tests/pool_test.ts b/tests/pool_test.ts index fb7c3fc..c8ecac9 100644 --- a/tests/pool_test.ts +++ b/tests/pool_test.ts @@ -140,3 +140,15 @@ Deno.test( ); }), ); + +Deno.test( + "Pool client will be released after `using` block", + testPool(async (POOL) => { + const initialPoolAvailable = POOL.available; + { + using _client = await POOL.connect(); + assertEquals(POOL.available, initialPoolAvailable - 1); + } + assertEquals(POOL.available, initialPoolAvailable); + }), +);