Fix: use .finally() to change schema back to original
This commit is contained in:
parent
eb5732003e
commit
51f9f86fa9
1 changed files with 1 additions and 10 deletions
11
lib/db.js
11
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({
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue