From eb20eebe95761ec6486177001229b286a90bc2c7 Mon Sep 17 00:00:00 2001 From: Raymond Feng Date: Fri, 3 Jul 2015 09:29:17 -0700 Subject: [PATCH] Fix the regression for date conversion --- lib/dao.js | 2 +- test/memory.test.js | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/lib/dao.js b/lib/dao.js index f987f96a..326b64f0 100644 --- a/lib/dao.js +++ b/lib/dao.js @@ -1173,7 +1173,7 @@ DataAccessObject._coerce = function (where) { break; } } - } else + } // Coerce the array items if (Array.isArray(val)) { for (var i = 0; i < val.length; i++) { diff --git a/test/memory.test.js b/test/memory.test.js index 8838720e..dfa75b75 100644 --- a/test/memory.test.js +++ b/test/memory.test.js @@ -270,6 +270,15 @@ describe('Memory connector', function() { }); }); + it('should successfully extract 2 users using date range', function(done) { + User.find({where: {birthday: {between: + [new Date(1940, 0).toISOString(), new Date(1990, 0).toISOString()]}}}, + function(err, users) { + should(users.length).be.equal(2); + done(); + }); + }); + it('should successfully extract 0 user from the db', function(done) { User.find({where: {birthday: {between: [new Date(1990,0), Date.now()]}}}, function(err, users) { @@ -278,6 +287,14 @@ describe('Memory connector', function() { }); }); + it('should count using date string', function(done) { + User.count({birthday: {lt: new Date(1990,0).toISOString()}}, + function(err, count) { + should(count).be.equal(2); + done(); + }); + }); + it('should support order with multiple fields', function(done) { User.find({order: 'vip ASC, seq DESC'}, function(err, posts) { should.not.exist(err);