From 0ac7a7738182711769826a86d6cfc8a046816a9e Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Mon, 12 Aug 2013 04:12:10 -0400 Subject: [PATCH] Show bound parameters for async queries --- chrome/content/zotero/xpcom/db.js | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/chrome/content/zotero/xpcom/db.js b/chrome/content/zotero/xpcom/db.js index d1e89a57f2..e4f63e62bd 100644 --- a/chrome/content/zotero/xpcom/db.js +++ b/chrome/content/zotero/xpcom/db.js @@ -854,7 +854,15 @@ Zotero.DBConnection.prototype.queryAsync = function (sql, params) { then(function (c) { conn = c; [sql, params] = self.parseQueryAndParams(sql, params); - Zotero.debug(sql, 5); + if (Zotero.Debug.enabled) { + Zotero.debug(sql, 5); + for each(let param in params) { + let paramType = typeof param; + let msg = "Binding parameter of type " + paramType + ": "; + msg += paramType == 'string' ? "'" + param + "'" : param; + Zotero.debug(msg, 5); + } + } return conn.executeCached(sql, params); }) .then(function (rows) { @@ -912,7 +920,15 @@ Zotero.DBConnection.prototype.valueQueryAsync = function (sql, params) { return this._getConnectionAsync(). then(function (conn) { [sql, params] = self.parseQueryAndParams(sql, params); - Zotero.debug(sql, 5); + if (Zotero.Debug.enabled) { + Zotero.debug(sql, 5); + for each(let param in params) { + let paramType = typeof param; + let msg = "Binding parameter of type " + paramType + ": "; + msg += paramType == 'string' ? "'" + param + "'" : param; + Zotero.debug(msg, 5); + } + } return conn.executeCached(sql, params); }) .then(function (rows) { @@ -960,7 +976,15 @@ Zotero.DBConnection.prototype.columnQueryAsync = function (sql, params) { then(function (c) { conn = c; [sql, params] = self.parseQueryAndParams(sql, params); - Zotero.debug(sql, 5); + if (Zotero.Debug.enabled) { + Zotero.debug(sql, 5); + for each(let param in params) { + let paramType = typeof param; + let msg = "Binding parameter of type " + paramType + ": "; + msg += paramType == 'string' ? "'" + param + "'" : param; + Zotero.debug(msg, 5); + } + } return conn.executeCached(sql, params); }) .then(function (rows) {