pqb 0.57.4 → 0.57.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +7 -3
- package/dist/index.js +35 -16
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +35 -16
- package/dist/index.mjs.map +1 -1
- package/dist/node-postgres.d.ts +7 -6
- package/dist/node-postgres.js +73 -12
- package/dist/node-postgres.js.map +1 -1
- package/dist/node-postgres.mjs +73 -12
- package/dist/node-postgres.mjs.map +1 -1
- package/dist/postgres-js.d.ts +7 -6
- package/dist/postgres-js.js +44 -16
- package/dist/postgres-js.js.map +1 -1
- package/dist/postgres-js.mjs +44 -16
- package/dist/postgres-js.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -3618,11 +3618,11 @@ const isQueryReturnsAll = (q) => !q.q.returnType || q.q.returnType === "all";
|
|
|
3618
3618
|
function simpleColumnToSQL(ctx, key, column, quotedAs) {
|
|
3619
3619
|
if (!column) return `"${key}"`;
|
|
3620
3620
|
const { data } = column;
|
|
3621
|
-
return data.computed ? data.computed.toSQL(ctx, quotedAs) : `${quotedAs ? `${quotedAs}.` : ""}"${data.name || key}"`;
|
|
3621
|
+
return data.computed ? `(${data.computed.toSQL(ctx, quotedAs)})` : `${quotedAs ? `${quotedAs}.` : ""}"${data.name || key}"`;
|
|
3622
3622
|
}
|
|
3623
3623
|
function simpleExistingColumnToSQL(ctx, key, column, quotedAs) {
|
|
3624
3624
|
const { data } = column;
|
|
3625
|
-
return data.computed ? data.computed.toSQL(ctx, quotedAs) : `${quotedAs ? `${quotedAs}.` : ""}"${data.name || key}"`;
|
|
3625
|
+
return data.computed ? `(${data.computed.toSQL(ctx, quotedAs)})` : `${quotedAs ? `${quotedAs}.` : ""}"${data.name || key}"`;
|
|
3626
3626
|
}
|
|
3627
3627
|
const columnToSql = (ctx, data, shape, column, quotedAs, select) => {
|
|
3628
3628
|
const index = column.indexOf(".");
|
|
@@ -3677,7 +3677,7 @@ const columnWithDotToSql = (ctx, data, shape, column, index, quotedAs, select) =
|
|
|
3677
3677
|
return `"${tableName}"."${col.data.name}"`;
|
|
3678
3678
|
}
|
|
3679
3679
|
if (col.data.computed) {
|
|
3680
|
-
return col.data.computed.toSQL(ctx, quoted)
|
|
3680
|
+
return `(${col.data.computed.toSQL(ctx, quoted)})`;
|
|
3681
3681
|
}
|
|
3682
3682
|
return `"${tableName}"."${key}"`;
|
|
3683
3683
|
}
|
|
@@ -3717,7 +3717,7 @@ const tableColumnToSqlWithAs = (ctx, data, column, table, key, as, quotedAs, sel
|
|
|
3717
3717
|
return `"${tableName}"."${col.data.name}" "${as}"`;
|
|
3718
3718
|
}
|
|
3719
3719
|
if (col.data.computed) {
|
|
3720
|
-
return
|
|
3720
|
+
return `(${col.data.computed.toSQL(ctx, quoted)}) "${as}"`;
|
|
3721
3721
|
}
|
|
3722
3722
|
}
|
|
3723
3723
|
return `"${tableName}"."${key}"${key === as ? "" : ` "${as}"`}`;
|
|
@@ -3730,7 +3730,7 @@ const ownColumnToSqlWithAs = (ctx, data, column, as, quotedAs, select, jsonList)
|
|
|
3730
3730
|
return `${quotedAs ? `${quotedAs}.` : ""}"${col.data.name}"${col.data.name === as ? "" : ` "${as}"`}`;
|
|
3731
3731
|
}
|
|
3732
3732
|
if (col.data.computed) {
|
|
3733
|
-
return
|
|
3733
|
+
return `(${col.data.computed.toSQL(ctx, quotedAs)}) "${as}"`;
|
|
3734
3734
|
}
|
|
3735
3735
|
}
|
|
3736
3736
|
return `${quotedAs ? `${quotedAs}.` : ""}"${column}"${column === as ? "" : ` "${as}"`}`;
|
|
@@ -4245,7 +4245,8 @@ const skipQueryKeysForSubQuery = {
|
|
|
4245
4245
|
catchAfterCommitErrors: true,
|
|
4246
4246
|
log: true,
|
|
4247
4247
|
logger: true,
|
|
4248
|
-
autoPreparedStatements: true
|
|
4248
|
+
autoPreparedStatements: true,
|
|
4249
|
+
catch: true
|
|
4249
4250
|
};
|
|
4250
4251
|
const getIsJoinSubQuery = (query) => {
|
|
4251
4252
|
const {
|
|
@@ -6167,12 +6168,16 @@ const queryMethodByReturnType = {
|
|
|
6167
6168
|
class Then {
|
|
6168
6169
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
6169
6170
|
catch(fn) {
|
|
6170
|
-
|
|
6171
|
+
const q = _clone(this);
|
|
6172
|
+
q.q.catch = true;
|
|
6173
|
+
return q.then(void 0, fn);
|
|
6171
6174
|
}
|
|
6172
6175
|
catchUniqueError(fn) {
|
|
6173
|
-
|
|
6176
|
+
const q = _clone(this);
|
|
6177
|
+
q.q.catch = true;
|
|
6178
|
+
return q.then(void 0, (err) => {
|
|
6174
6179
|
if (err instanceof QueryError && err.isUnique) {
|
|
6175
|
-
fn(err);
|
|
6180
|
+
return fn(err);
|
|
6176
6181
|
} else {
|
|
6177
6182
|
throw err;
|
|
6178
6183
|
}
|
|
@@ -6195,6 +6200,7 @@ Object.defineProperty(Then.prototype, "then", {
|
|
|
6195
6200
|
});
|
|
6196
6201
|
function maybeWrappedThen(resolve, reject) {
|
|
6197
6202
|
const { q } = this;
|
|
6203
|
+
const shouldCatch = q.catch || !!reject;
|
|
6198
6204
|
let beforeHooks;
|
|
6199
6205
|
let afterHooks;
|
|
6200
6206
|
let afterCommitHooks;
|
|
@@ -6226,7 +6232,8 @@ function maybeWrappedThen(resolve, reject) {
|
|
|
6226
6232
|
afterHooks,
|
|
6227
6233
|
afterCommitHooks,
|
|
6228
6234
|
resolve2,
|
|
6229
|
-
reject2
|
|
6235
|
+
reject2,
|
|
6236
|
+
shouldCatch
|
|
6230
6237
|
);
|
|
6231
6238
|
})
|
|
6232
6239
|
).then(resolve, reject);
|
|
@@ -6239,7 +6246,8 @@ function maybeWrappedThen(resolve, reject) {
|
|
|
6239
6246
|
afterHooks,
|
|
6240
6247
|
afterCommitHooks,
|
|
6241
6248
|
resolve,
|
|
6242
|
-
reject
|
|
6249
|
+
reject,
|
|
6250
|
+
shouldCatch
|
|
6243
6251
|
);
|
|
6244
6252
|
}
|
|
6245
6253
|
}
|
|
@@ -6249,7 +6257,7 @@ const callAfterHook = function(cb) {
|
|
|
6249
6257
|
return cb(this[0], this[1]);
|
|
6250
6258
|
};
|
|
6251
6259
|
const beginSql = { text: "BEGIN" };
|
|
6252
|
-
const then = async (q, adapter, trx, beforeHooks, afterHooks, afterCommitHooks, resolve, reject) => {
|
|
6260
|
+
const then = async (q, adapter, trx, beforeHooks, afterHooks, afterCommitHooks, resolve, reject, shouldCatch) => {
|
|
6253
6261
|
var _a;
|
|
6254
6262
|
const { q: query } = q;
|
|
6255
6263
|
let sql;
|
|
@@ -6282,7 +6290,8 @@ const then = async (q, adapter, trx, beforeHooks, afterHooks, afterCommitHooks,
|
|
|
6282
6290
|
queryResult = await execQuery(
|
|
6283
6291
|
adapter,
|
|
6284
6292
|
queryMethodByReturnType[tempReturnType],
|
|
6285
|
-
sql
|
|
6293
|
+
sql,
|
|
6294
|
+
shouldCatch && trx
|
|
6286
6295
|
);
|
|
6287
6296
|
if (log) {
|
|
6288
6297
|
log.afterQuery(sql, logData);
|
|
@@ -6312,7 +6321,12 @@ const then = async (q, adapter, trx, beforeHooks, afterHooks, afterCommitHooks,
|
|
|
6312
6321
|
if (log) {
|
|
6313
6322
|
logData = log.beforeQuery(sql);
|
|
6314
6323
|
}
|
|
6315
|
-
const result2 = await execQuery(
|
|
6324
|
+
const result2 = await execQuery(
|
|
6325
|
+
adapter,
|
|
6326
|
+
queryMethod,
|
|
6327
|
+
sql,
|
|
6328
|
+
shouldCatch && trx
|
|
6329
|
+
);
|
|
6316
6330
|
if (queryResult) {
|
|
6317
6331
|
queryResult.rowCount += result2.rowCount;
|
|
6318
6332
|
queryResult.rows.push(...result2.rows);
|
|
@@ -6584,8 +6598,13 @@ const then = async (q, adapter, trx, beforeHooks, afterHooks, afterCommitHooks,
|
|
|
6584
6598
|
throw error;
|
|
6585
6599
|
}
|
|
6586
6600
|
};
|
|
6587
|
-
const execQuery = (adapter, method, sql) => {
|
|
6588
|
-
|
|
6601
|
+
const execQuery = (adapter, method, sql, catchTrx) => {
|
|
6602
|
+
const catchingSavepoint = catchTrx ? String(catchTrx.catchI = (catchTrx.catchI || 0) + 1) : void 0;
|
|
6603
|
+
return adapter[method](
|
|
6604
|
+
sql.text,
|
|
6605
|
+
sql.values,
|
|
6606
|
+
catchingSavepoint
|
|
6607
|
+
).then((result) => {
|
|
6589
6608
|
if (result.rowCount && !result.rows.length) {
|
|
6590
6609
|
result.rows.length = result.rowCount;
|
|
6591
6610
|
result.rows.fill({});
|