Open impfromliga opened 5 years ago
Perhaps some where in the library the fact of property $exists check like if(property) or etc. Or i'm bad understand the rule that $exists "return true". In case of array follows that [] not $exists, and not not $exist! such a quantum mechanics of data base...
@impfromliga Can you confirm that your data set also contained 111 records with an empty array value ([]
) for the arr
property?
I added some quick checks to various array values in the tests to try to reproduce this. It appears that an empty array fails to match on both $exists: true
and $exists: false
.
model.match({ a: [5, 6] }, { a: { $exists: true } }).should.equal(true);
model.match({ a: [5] }, { a: { $exists: true } }).should.equal(true);
model.match({ a: [5] }, { b: { $exists: false } }).should.equal(true);
model.match({ a: [0] }, { a: { $exists: true } }).should.equal(true);
model.match({ a: [null] }, { a: { $exists: true } }).should.equal(true);
model.match({ a: [] }, { a: { $exists: false } }).should.equal(false);
model.match({ a: [] }, { a: { $exists: true } }).should.equal(true); // UNEXPECTED FAIL
//strange result with $exists on Arrays: