commit
0f548ed9ac
|
@ -1182,6 +1182,7 @@ SQLConnector.prototype._buildWhere = function(model, where) {
|
|||
let params = [];
|
||||
const sqls = [];
|
||||
for (let k = 0, s = whereStmts.length; k < s; k++) {
|
||||
if (!whereStmts[k].sql) continue;
|
||||
sqls.push(whereStmts[k].sql);
|
||||
params = params.concat(whereStmts[k].params);
|
||||
}
|
||||
|
|
|
@ -247,6 +247,14 @@ describe('sql connector', function() {
|
|||
});
|
||||
});
|
||||
|
||||
it('builds where and ignores invalid clauses in or', function() {
|
||||
const where = connector.buildWhere('customer', {
|
||||
name: 'icecream',
|
||||
or: [{notAColumnName: ''}, {notAColumnNameEither: ''}],
|
||||
});
|
||||
expect(where.sql).to.not.match(/ AND $/);
|
||||
});
|
||||
|
||||
it('builds order by with one field', function() {
|
||||
const orderBy = connector.buildOrderBy('customer', 'name');
|
||||
expect(orderBy).to.eql('ORDER BY `NAME`');
|
||||
|
|
Loading…
Reference in New Issue