Fix buildWhere
This commit is contained in:
parent
1103a9e919
commit
7332f12972
11
lib/mysql.js
11
lib/mysql.js
|
@ -389,6 +389,11 @@ MySQL.prototype.getColumns = function (model, props) {
|
|||
};
|
||||
|
||||
MySQL.prototype.buildWhere = function (model, conds) {
|
||||
var where = this._buildWhere(model, conds);
|
||||
return where? 'WHERE ' + where : '';
|
||||
};
|
||||
|
||||
MySQL.prototype._buildWhere = function (model, conds) {
|
||||
var self = this;
|
||||
var props = self._models[model].properties;
|
||||
|
||||
|
@ -398,9 +403,9 @@ MySQL.prototype.buildWhere = function (model, conds) {
|
|||
var clauses = conds[key];
|
||||
if (Array.isArray(clauses)) {
|
||||
clauses = clauses.map(function (c) {
|
||||
return '(' + self.buildWhere(model, c) + ')';
|
||||
return '(' + self._buildWhere(model, c) + ')';
|
||||
});
|
||||
return clauses.join(' ' + key.toUpperCase() + ' ');
|
||||
return cs.push(clauses.join(' ' + key.toUpperCase() + ' '));
|
||||
}
|
||||
// The value is not an array, fall back to regular fields
|
||||
}
|
||||
|
@ -450,7 +455,7 @@ MySQL.prototype.buildWhere = function (model, conds) {
|
|||
if (cs.length === 0) {
|
||||
return '';
|
||||
}
|
||||
return 'WHERE ' + cs.join(' AND ');
|
||||
return cs.join(' AND ');
|
||||
}
|
||||
|
||||
function buildOrderBy(self, model, order) {
|
||||
|
|
Loading…
Reference in New Issue