From 602043606375ccc8bcbae8ee3795322793a5b1dd Mon Sep 17 00:00:00 2001 From: Raymond Feng Date: Tue, 2 Sep 2014 08:36:37 -0700 Subject: [PATCH] Added a test case for neq --- lib/connectors/memory.js | 6 ++++-- test/memory.test.js | 11 +++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/lib/connectors/memory.js b/lib/connectors/memory.js index 99b05230..5ef4d43b 100644 --- a/lib/connectors/memory.js +++ b/lib/connectors/memory.js @@ -409,6 +409,7 @@ function applyFilter(filter) { if (example === undefined) { return undefined; } + if (typeof example === 'object') { // ignore geo near filter if (example.near) { @@ -425,7 +426,7 @@ function applyFilter(filter) { return false; } - if (example.neq) { + if ('neq' in example) { return compare(example.neq, value) !== 0; } @@ -449,7 +450,8 @@ function applyFilter(filter) { } } // not strict equality - return (example !== null ? example.toString() : example) == (value != null ? value.toString() : value); + return (example !== null ? example.toString() : example) + == (value != null ? value.toString() : value); } /** diff --git a/test/memory.test.js b/test/memory.test.js index 4fb2c934..453ac9e8 100644 --- a/test/memory.test.js +++ b/test/memory.test.js @@ -223,6 +223,17 @@ describe('Memory connector', function () { }); }); + it('should support neq operator for null', function (done) { + User.find({where: {role: {neq: null}}}, function (err, users) { + should.not.exist(err); + users.length.should.be.equal(2); + for (var i = 0; i < users.length; i++) { + should.exist(users[i].role); + } + done(); + }); + }); + function seed(done) { var beatles = [ {