commit 86b94ae713dc600927ac3949c07bdb83e063ea13 parent 52737ec69431077c53f5a3aa843ba45c210d0580 Author: Dan Stillman <dstillman@zotero.org> Date: Fri, 4 May 2018 19:52:14 -0400 Add optional 'db' parameter to Zotero.DB.tableExists() To check attached databases Diffstat:
| M | chrome/content/zotero/xpcom/db.js | | | 5 | +++-- |
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/chrome/content/zotero/xpcom/db.js b/chrome/content/zotero/xpcom/db.js @@ -818,9 +818,10 @@ Zotero.DBConnection.prototype.logQuery = function (sql, params = [], options) { } -Zotero.DBConnection.prototype.tableExists = Zotero.Promise.coroutine(function* (table) { +Zotero.DBConnection.prototype.tableExists = Zotero.Promise.coroutine(function* (table, db) { yield this._getConnectionAsync(); - var sql = "SELECT COUNT(*) FROM sqlite_master WHERE type='table' AND tbl_name=?"; + var prefix = db ? db + '.' : ''; + var sql = `SELECT COUNT(*) FROM ${prefix}sqlite_master WHERE type='table' AND tbl_name=?`; var count = yield this.valueQueryAsync(sql, [table]); return !!count; });