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