commit 6faa2caff8da24513bb99ed798529dd8df28b3f7
parent aa70e60fc624f697a03c87947b7f748a03ef330a
Author: Dan Stillman <dstillman@zotero.org>
Date: Sun, 10 May 2015 04:23:33 -0400
Add queryTx() to a run a single query in a transaction
Otherwise a write statement could run in the middle of an unrelated open
transaction.
Diffstat:
1 file changed, 9 insertions(+), 0 deletions(-)
diff --git a/chrome/content/zotero/xpcom/db.js b/chrome/content/zotero/xpcom/db.js
@@ -699,6 +699,15 @@ Zotero.DBConnection.prototype.queryAsync = function (sql, params, options) {
};
+Zotero.DBConnection.prototype.queryTx = function (sql, params, options) {
+ return this.executeTransaction(function* () {
+ options = options || {};
+ delete options.tx;
+ return this.queryAsync(sql, params, options);
+ }.bind(this));
+};
+
+
/**
* @param {String} sql SQL statement to run
* @param {Array|String|Integer} [params] SQL parameters to bind