diff --git a/lib/db.js b/lib/db.js index 8255f32c..dff97ba6 100644 --- a/lib/db.js +++ b/lib/db.js @@ -9,13 +9,13 @@ const extendedQueries = require('./extendedQueries') const pgp = Pgp({ pgNative: true, extend (obj, dbContext) { - obj.taskEx = function () { + obj._taskEx = function () { const args = pgp.utils.taskArgs(arguments) const { schema } = args.options delete args.options.schema if (schema) { return obj.task.call(this, args.options, t => { - return t.none('SET search_path to $1:name', [schema]) + return t.none('SET search_path TO $1:name', [schema]) .then(args.cb.bind(t, t)) }) } diff --git a/lib/extendedQueries.js b/lib/extendedQueries.js index c388f2c2..a69de680 100644 --- a/lib/extendedQueries.js +++ b/lib/extendedQueries.js @@ -31,7 +31,7 @@ const stripDefaultDbFuncs = dbCtx => { const any = (obj, query, variables) => { const schema = getSchema() if (!schema) throw new Error(schemaNotFound(query)) - return obj.taskEx({ schema }, t => { + return obj._taskEx({ schema }, t => { return t.any(query, variables).then(res => { return t.none('set search_path to $1~', [getDefaultSchema()]).then(() => { return res @@ -43,7 +43,7 @@ const any = (obj, query, variables) => { const none = (obj, query, variables) => { const schema = getSchema() if (!schema) throw new Error(schemaNotFound(query)) - return obj.taskEx({ schema }, t => { + return obj._taskEx({ schema }, t => { return t.none(query, variables).then(res => { return t.none('set search_path to $1~', [getDefaultSchema()]).then(() => { return res @@ -55,7 +55,7 @@ const none = (obj, query, variables) => { const one = (obj, query, variables) => { const schema = getSchema() if (!schema) throw new Error(schemaNotFound(query)) - return obj.taskEx({ schema }, t => { + return obj._taskEx({ schema }, t => { return t.one(query, variables).then(res => { return t.none('set search_path to $1~', [getDefaultSchema()]).then(() => { return res @@ -67,7 +67,7 @@ const one = (obj, query, variables) => { const oneOrNone = (obj, query, variables) => { const schema = getSchema() if (!schema) throw new Error(schemaNotFound(query)) - return obj.taskEx({ schema }, t => { + return obj._taskEx({ schema }, t => { return t.oneOrNone(query, variables).then(res => { return t.none('set search_path to $1~', [getDefaultSchema()]).then(() => { return res @@ -79,7 +79,7 @@ const oneOrNone = (obj, query, variables) => { const manyOrNone = (obj, query, variables) => { const schema = getSchema() if (!schema) throw new Error(schemaNotFound(query)) - return obj.taskEx({ schema }, t => { + return obj._taskEx({ schema }, t => { return t.manyOrNone(query, variables).then(res => { return t.none('set search_path to $1~', [getDefaultSchema()]).then(() => { return res @@ -91,7 +91,7 @@ const manyOrNone = (obj, query, variables) => { const many = (obj, query, variables) => { const schema = getSchema() if (!schema) throw new Error(schemaNotFound(query)) - return obj.taskEx({ schema }, t => { + return obj._taskEx({ schema }, t => { return t.many(query, variables).then(res => { return t.none('set search_path to $1~', [getDefaultSchema()]).then(() => { return res @@ -103,7 +103,7 @@ const many = (obj, query, variables) => { const result = (obj, query, variables, cb, thisArg) => { const schema = getSchema() if (!schema) throw new Error(schemaNotFound(query)) - return obj.taskEx({ schema }, t => { + return obj._taskEx({ schema }, t => { return t.result(query, variables, cb, thisArg).then(res => { return t.none('set search_path to $1~', [getDefaultSchema()]).then(() => { return res @@ -118,7 +118,7 @@ const query = (obj, query, variables, qrm, throwOnError) => { if (throwOnError) throw new Error(schemaNotFound(query)) return Promise.resolve(schemaNotFound(query)) } - return obj.taskEx({ schema }, t => { + return obj._taskEx({ schema }, t => { return t.query(query, variables, qrm).then(res => { return t.none('set search_path to $1~', [getDefaultSchema()]).then(() => { return res