Fix the count() impl to use buildWhere() from the subclass

This commit is contained in:
Raymond Feng 2014-06-03 07:59:27 -07:00
parent b2520029bf
commit 1553452346
1 changed files with 7 additions and 1 deletions

View File

@ -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);
}