From 51f9f86fa9c7eaca05f190e5ca6a82e9c80f2dac Mon Sep 17 00:00:00 2001 From: csrapr <26280794+csrapr@users.noreply.github.com> Date: Mon, 14 Jun 2021 16:05:51 +0100 Subject: [PATCH] Fix: use .finally() to change schema back to original --- lib/db.js | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/lib/db.js b/lib/db.js index 7cada8dc..04d8e937 100644 --- a/lib/db.js +++ b/lib/db.js @@ -38,16 +38,7 @@ const getDefaultSchema = () => 'ERROR_SCHEMA' const searchPathWrapper = (t, cb) => { return t.none('SET search_path TO $1:name', [getSchema()]) .then(cb.bind(t, t)) - .then(res => { - return t.none('SET search_path TO $1:name', [getDefaultSchema()]).then(() => { - return res - }) - }) - .catch(err => { - return t.none('SET search_path TO $1:name', [getDefaultSchema()]).then(() => { - throw err - }) - }) + .finally(() => t.none('SET search_path TO $1:name', [getDefaultSchema()])) } const pgp = Pgp({