pqb 0.38.4 → 0.38.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.js +24 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +24 -12
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -3278,18 +3278,7 @@ class Transaction {
|
|
|
3278
3278
|
const result = await this.q.adapter.transaction(sql, callback);
|
|
3279
3279
|
if (log)
|
|
3280
3280
|
log.afterQuery(commitSql$1, logData);
|
|
3281
|
-
|
|
3282
|
-
if (afterCommit) {
|
|
3283
|
-
const promises = [];
|
|
3284
|
-
for (let i = 0, len = afterCommit.length; i < len; i += 2) {
|
|
3285
|
-
const q = afterCommit[i];
|
|
3286
|
-
const result2 = afterCommit[i + 1];
|
|
3287
|
-
for (const fn2 of afterCommit[i + 2]) {
|
|
3288
|
-
promises.push(fn2(result2, q));
|
|
3289
|
-
}
|
|
3290
|
-
}
|
|
3291
|
-
await Promise.all(promises);
|
|
3292
|
-
}
|
|
3281
|
+
await runAfterCommit(trx.afterCommit);
|
|
3293
3282
|
return result;
|
|
3294
3283
|
} catch (err) {
|
|
3295
3284
|
if (log)
|
|
@@ -3321,6 +3310,11 @@ class Transaction {
|
|
|
3321
3310
|
await adapter.query(sql);
|
|
3322
3311
|
if (log)
|
|
3323
3312
|
log.afterQuery(sql, logData);
|
|
3313
|
+
if (transactionId === trx.testTransactionCount) {
|
|
3314
|
+
await runAfterCommit(
|
|
3315
|
+
trx.afterCommit
|
|
3316
|
+
);
|
|
3317
|
+
}
|
|
3324
3318
|
return result;
|
|
3325
3319
|
} finally {
|
|
3326
3320
|
trx.transactionId = transactionId - 1;
|
|
@@ -3328,6 +3322,19 @@ class Transaction {
|
|
|
3328
3322
|
}
|
|
3329
3323
|
}
|
|
3330
3324
|
}
|
|
3325
|
+
const runAfterCommit = async (afterCommit) => {
|
|
3326
|
+
if (afterCommit) {
|
|
3327
|
+
const promises = [];
|
|
3328
|
+
for (let i = 0, len = afterCommit.length; i < len; i += 3) {
|
|
3329
|
+
const result = afterCommit[i];
|
|
3330
|
+
const q = afterCommit[i + 1];
|
|
3331
|
+
for (const fn of afterCommit[i + 2]) {
|
|
3332
|
+
promises.push(fn(result, q));
|
|
3333
|
+
}
|
|
3334
|
+
}
|
|
3335
|
+
await Promise.all(promises);
|
|
3336
|
+
}
|
|
3337
|
+
};
|
|
3331
3338
|
|
|
3332
3339
|
const applyBatchTransforms = (query, batches) => {
|
|
3333
3340
|
if (query.transform) {
|
|
@@ -12704,6 +12711,7 @@ const testTransaction = {
|
|
|
12704
12711
|
adapter.query = t.query.bind(t);
|
|
12705
12712
|
adapter.arrays = t.arrays.bind(t);
|
|
12706
12713
|
adapter.transaction = t.transaction.bind(t);
|
|
12714
|
+
trx.testTransactionCount = trx.testTransactionCount ? trx.testTransactionCount + 1 : 1;
|
|
12707
12715
|
}
|
|
12708
12716
|
data.reject = rej;
|
|
12709
12717
|
});
|
|
@@ -12712,6 +12720,10 @@ const testTransaction = {
|
|
|
12712
12720
|
throw err;
|
|
12713
12721
|
}
|
|
12714
12722
|
}).finally(() => {
|
|
12723
|
+
const trx = db.internal.transactionStorage.getStore();
|
|
12724
|
+
if (trx == null ? void 0 : trx.testTransactionCount) {
|
|
12725
|
+
trx.testTransactionCount--;
|
|
12726
|
+
}
|
|
12715
12727
|
db.internal.transactionStorage.getStore = getStore;
|
|
12716
12728
|
});
|
|
12717
12729
|
});
|