Correction of a regression introduced by commit 632898b: when querying an empty array ([]) with a 'neq' filter, there were no matching.
This commit is contained in:
parent
84e606bc59
commit
d8678a1f03
|
@ -421,6 +421,11 @@ function applyFilter(filter) {
|
||||||
// Also support array types. Mongo, possibly PostgreSQL
|
// Also support array types. Mongo, possibly PostgreSQL
|
||||||
if (Array.isArray(value)) {
|
if (Array.isArray(value)) {
|
||||||
var matcher = where[key];
|
var matcher = where[key];
|
||||||
|
// The following condition is for the case where we are querying with
|
||||||
|
// a neq filter, and when the value is an empty array ([]).
|
||||||
|
if (matcher.neq !== undefined && value.length <= 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
return value.some(function (v, i) {
|
return value.some(function (v, i) {
|
||||||
var filter = {where: {}};
|
var filter = {where: {}};
|
||||||
filter.where[i] = matcher;
|
filter.where[i] = matcher;
|
||||||
|
|
|
@ -338,6 +338,19 @@ describe('Memory connector', function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should successfully extract 5 users matching a neq filter over array values', function (done) {
|
||||||
|
User.find({
|
||||||
|
where: {
|
||||||
|
'children': {neq: 'Dhani'}
|
||||||
|
}
|
||||||
|
}, function (err, users) {
|
||||||
|
should.not.exist(err);
|
||||||
|
console.log(users);
|
||||||
|
users.length.should.be.equal(5);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it('should count using date string', function(done) {
|
it('should count using date string', function(done) {
|
||||||
User.count({birthday: {lt: new Date(1990,0).toISOString()}},
|
User.count({birthday: {lt: new Date(1990,0).toISOString()}},
|
||||||
function(err, count) {
|
function(err, count) {
|
||||||
|
@ -546,7 +559,7 @@ describe('Memory connector', function() {
|
||||||
},
|
},
|
||||||
{seq: 2, name: 'George Harrison', order: 5, vip: false, children: ['Dhani']},
|
{seq: 2, name: 'George Harrison', order: 5, vip: false, children: ['Dhani']},
|
||||||
{seq: 3, name: 'Ringo Starr', order: 6, vip: false},
|
{seq: 3, name: 'Ringo Starr', order: 6, vip: false},
|
||||||
{seq: 4, name: 'Pete Best', order: 4},
|
{seq: 4, name: 'Pete Best', order: 4, children: []},
|
||||||
{seq: 5, name: 'Stuart Sutcliffe', order: 3, vip: true}
|
{seq: 5, name: 'Stuart Sutcliffe', order: 3, vip: true}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue