only invoke afterCommitCallback for transactions that change data

This commit is contained in:
Florian Dold 2019-08-16 22:35:44 +02:00
parent 705699b2d2
commit 262885679c
No known key found for this signature in database
GPG Key ID: D2E4F00F29D02A4B
2 changed files with 5 additions and 3 deletions

View File

@ -1416,7 +1416,8 @@ export class MemoryBackend implements Backend {
if (!db) {
throw Error("db not found");
}
if (db.txLevel < TransactionLevel.Read) {
const txLevel = db.txLevel;
if (txLevel < TransactionLevel.Read) {
throw Error("only allowed while running a transaction");
}
@ -1455,7 +1456,7 @@ export class MemoryBackend implements Backend {
delete this.connectionsByTransaction[btx.transactionCookie];
this.transactionDoneCond.trigger();
if (this.afterCommitCallback) {
if (this.afterCommitCallback && txLevel >= TransactionLevel.Write) {
await this.afterCommitCallback();
}
}

View File

@ -9,7 +9,8 @@
"noEmitOnError": true,
"strict": true,
"incremental": true,
"sourceMap": true
"sourceMap": true,
"types": []
},
"include": ["src/**/*"]
}