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) => {
|
const searchPathWrapper = (t, cb) => {
|
||||||
return t.none('SET search_path TO $1:name', [getSchema()])
|
return t.none('SET search_path TO $1:name', [getSchema()])
|
||||||
.then(cb.bind(t, t))
|
.then(cb.bind(t, t))
|
||||||
.then(res => {
|
.finally(() => t.none('SET search_path TO $1:name', [getDefaultSchema()]))
|
||||||
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
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const pgp = Pgp({
|
const pgp = Pgp({
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue