Test for nested transaction failures
This commit is contained in:
parent
ba9adffa68
commit
8c32210507
1 changed files with 21 additions and 0 deletions
|
@ -82,5 +82,26 @@ describe("Zotero.DB", function() {
|
||||||
|
|
||||||
yield Zotero.DB.queryAsync("DROP TABLE " + tmpTable);
|
yield Zotero.DB.queryAsync("DROP TABLE " + tmpTable);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should not commit nested transactions", function* () {
|
||||||
|
var tmpTable = "tmpNoCommitNested";
|
||||||
|
yield Zotero.DB.queryAsync("CREATE TABLE " + tmpTable + " (foo INT)");
|
||||||
|
try {
|
||||||
|
yield Zotero.DB.executeTransaction(function* () {
|
||||||
|
yield Zotero.DB.queryAsync("INSERT INTO " + tmpTable + " VALUES (1)");
|
||||||
|
yield Zotero.DB.executeTransaction(function* () {
|
||||||
|
yield Zotero.DB.queryAsync("INSERT INTO " + tmpTable + " VALUES (2)");
|
||||||
|
throw 'Aborting transaction -- ignore';
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
if (typeof e != 'string' || !e.startsWith('Aborting transaction')) throw e;
|
||||||
|
}
|
||||||
|
var count = yield Zotero.DB.valueQueryAsync("SELECT COUNT(*) FROM " + tmpTable);
|
||||||
|
assert.equal(count, 0);
|
||||||
|
|
||||||
|
yield Zotero.DB.queryAsync("DROP TABLE " + tmpTable);
|
||||||
|
});
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue