From 6121a0afc100f968b50112b225a8e55660687160 Mon Sep 17 00:00:00 2001 From: Rasmus Porsager Date: Thu, 2 Nov 2023 08:44:19 +0100 Subject: [PATCH] build --- cf/src/connection.js | 11 +++++++---- cjs/src/connection.js | 11 +++++++---- cjs/tests/index.js | 11 +++++++++++ deno/src/connection.js | 11 +++++++---- deno/tests/index.js | 11 +++++++++++ 5 files changed, 43 insertions(+), 12 deletions(-) diff --git a/cf/src/connection.js b/cf/src/connection.js index f06a5f8b..ab977ca8 100644 --- a/cf/src/connection.js +++ b/cf/src/connection.js @@ -111,7 +111,7 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose queue: queues.closed, idleTimer, connect(query) { - initial = query + initial = query || true reconnect() }, terminate, @@ -535,11 +535,14 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose return terminate() } - if (needsTypes) + if (needsTypes) { + initial === true && (initial = null) return fetchArrayTypes() + } - execute(initial) - options.shared.retries = retries = initial = 0 + initial !== true && execute(initial) + options.shared.retries = retries = 0 + initial = null return } diff --git a/cjs/src/connection.js b/cjs/src/connection.js index b295958a..425e91cd 100644 --- a/cjs/src/connection.js +++ b/cjs/src/connection.js @@ -109,7 +109,7 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose queue: queues.closed, idleTimer, connect(query) { - initial = query + initial = query || true reconnect() }, terminate, @@ -533,11 +533,14 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose return terminate() } - if (needsTypes) + if (needsTypes) { + initial === true && (initial = null) return fetchArrayTypes() + } - execute(initial) - options.shared.retries = retries = initial = 0 + initial !== true && execute(initial) + options.shared.retries = retries = 0 + initial = null return } diff --git a/cjs/tests/index.js b/cjs/tests/index.js index ef70c4ab..5aa0ae15 100644 --- a/cjs/tests/index.js +++ b/cjs/tests/index.js @@ -2543,3 +2543,14 @@ t('reserve connection', async() => { xs.map(x => x.x).join('') ] }) + +t('arrays in reserved connection', async() => { + const reserved = await sql.reserve() + const [{ x }] = await reserved`select array[1, 2, 3] as x` + reserved.release() + + return [ + '123', + x.join('') + ] +}) diff --git a/deno/src/connection.js b/deno/src/connection.js index bc4d231c..334b9722 100644 --- a/deno/src/connection.js +++ b/deno/src/connection.js @@ -112,7 +112,7 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose queue: queues.closed, idleTimer, connect(query) { - initial = query + initial = query || true reconnect() }, terminate, @@ -536,11 +536,14 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose return terminate() } - if (needsTypes) + if (needsTypes) { + initial === true && (initial = null) return fetchArrayTypes() + } - execute(initial) - options.shared.retries = retries = initial = 0 + initial !== true && execute(initial) + options.shared.retries = retries = 0 + initial = null return } diff --git a/deno/tests/index.js b/deno/tests/index.js index dc78c2c8..90d1feeb 100644 --- a/deno/tests/index.js +++ b/deno/tests/index.js @@ -2546,4 +2546,15 @@ t('reserve connection', async() => { ] }) +t('arrays in reserved connection', async() => { + const reserved = await sql.reserve() + const [{ x }] = await reserved`select array[1, 2, 3] as x` + reserved.release() + + return [ + '123', + x.join('') + ] +}) + ;window.addEventListener("unload", () => Deno.exit(process.exitCode)) \ No newline at end of file