From 1553452346c4b24e507a444244504c2d2e0c286a Mon Sep 17 00:00:00 2001 From: Raymond Feng Date: Tue, 3 Jun 2014 07:59:27 -0700 Subject: [PATCH] Fix the count() impl to use buildWhere() from the subclass --- lib/sql.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/sql.js b/lib/sql.js index dcad57a..f7a2b32 100644 --- a/lib/sql.js +++ b/lib/sql.js @@ -297,8 +297,14 @@ SqlConnector.prototype.count = function count(model, callback, where) { var self = this; var props = this._models[model].properties; + var whereClause = ''; + if (typeof this.buildWhere === 'function') { + whereClause = this.buildWhere(model, where); + } else { + whereClause = buildWhere(where); + } this.queryOne('SELECT count(*) as cnt FROM ' + - this.tableEscaped(model) + ' ' + buildWhere(where), function (err, res) { + this.tableEscaped(model) + ' ' + whereClause, function (err, res) { if (err) { return callback(err); }