From c407b2119ef39d8d2831e64d5abecd4a684d1e74 Mon Sep 17 00:00:00 2001 From: Pavel Lang Date: Tue, 27 Feb 2024 15:53:52 +0100 Subject: [PATCH 1/2] feat: Allow `using` keyword with pool clients --- client.ts | 4 ++++ tests/pool_test.ts | 12 ++++++++++++ 2 files changed, 16 insertions(+) diff --git a/client.ts b/client.ts index 7635c6a3..d254188d 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/tests/pool_test.ts b/tests/pool_test.ts index fb7c3fcb..c8ecac91 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); + }), +); From 16ec1eb6a2b1d751de3d07547ec2f19d4f968e19 Mon Sep 17 00:00:00 2001 From: Pavel Lang Date: Wed, 28 Feb 2024 14:21:04 +0100 Subject: [PATCH 2/2] chore: fix deno lint error --- query/array_parser.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/query/array_parser.ts b/query/array_parser.ts index b7983b41..60e27a25 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(); }