Add a test for nesting and/or

This commit is contained in:
Raymond Feng 2015-06-24 23:03:13 -07:00
parent 6989cfc5fb
commit 98eeab1044
1 changed files with 9 additions and 0 deletions

View File

@ -128,6 +128,15 @@ describe('sql connector', function() {
});
});
it('builds where with nesting and/or', function() {
var where = connector.buildWhere('customer',
{and: [{name: 'John'}, {or: [{vip: true}, {address: null}]}]});
expect(where.toJSON()).to.eql({
sql: 'WHERE (`NAME`=?) AND ((`VIP`=?) OR (`ADDRESS` IS NULL))',
params: ['John', true]
});
});
it('builds order by with one field', function() {
var orderBy = connector.buildOrderBy('customer', 'name');
expect(orderBy).to.eql('ORDER BY `NAME`');