From 98eeab1044cd49f67d90d756a49e92d27d4a28b5 Mon Sep 17 00:00:00 2001 From: Raymond Feng Date: Wed, 24 Jun 2015 23:03:13 -0700 Subject: [PATCH] Add a test for nesting and/or --- test/sql.test.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/sql.test.js b/test/sql.test.js index 0488134..28fc7bb 100644 --- a/test/sql.test.js +++ b/test/sql.test.js @@ -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`');