Allow empty array or value of `order`
This commit is contained in:
parent
fa7a4b2d66
commit
1b1dc898fd
|
@ -1216,6 +1216,9 @@ SQLConnector.prototype.buildOrderBy = function(model, order) {
|
|||
clauses.push(self.columnEscaped(model, t[0]) + ' ' + t[1]);
|
||||
}
|
||||
}
|
||||
if (!clauses.length) {
|
||||
return '';
|
||||
}
|
||||
return 'ORDER BY ' + clauses.join(',');
|
||||
};
|
||||
|
||||
|
|
|
@ -270,6 +270,16 @@ describe('sql connector', function() {
|
|||
expect(orderBy).to.eql('ORDER BY `NAME` ASC,`VIP` DESC');
|
||||
});
|
||||
|
||||
it('builds order by with empty array', function() {
|
||||
const orderBy = connector.buildOrderBy('customer', []);
|
||||
expect(orderBy).to.eql('');
|
||||
});
|
||||
|
||||
it('builds order by with empty string', function() {
|
||||
const orderBy = connector.buildOrderBy('customer', '');
|
||||
expect(orderBy).to.eql('');
|
||||
});
|
||||
|
||||
it('builds fields for columns', function() {
|
||||
const fields = connector.buildFields('customer',
|
||||
{name: 'John', vip: true, unknown: 'Random'});
|
||||
|
|
Loading…
Reference in New Issue