You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We currently do not handle these cases correctly. Using the sample data.
varMingo=require("mingo");var_=Mingo._internal();varfixtures=[[{"key0.key1.key2.a": "value2"},[],"should not match without array index selector to nested value "],[{"key0.key1.0.key2.a": "value2"},[],"should not match without enough depth for array index selector to nested value"],[{"key0.key1.0.0.key2.a": "value2"},data,"should match with full array index selector to deeply nested value"],[{"key0.key1.0.0.key2": {b:20}},data,"should match with array index selector to nested value at depth 1"],[{"key0.key1.1.key2": "value"},data,"should match with full array index selector to nested value"],[{"key0.key1.key2": "value"},data,"should match without array index selector to nested value at depth 1"],[{"key0.key1.1.key2": "value"},data,"should match shallow nested value with array index selector"]];console.log("#Test 1: matching deep nested objects");fixtures.forEach(function(f){varquery=f[0],expect=f[1],msg=f[2];varresult=Mingo.find(data,query).all();console.log(_.isEqual(result,expect)+"> "+msg);});console.log(">>>>>>>>>>>>> finish test 1 <<<<<<<<<<<<<");console.log("#Test 2: matching whole objects");fixtures=[[{"key0.key1": [[{key2: [{a:"value2"},{a: "dummy"},{b:20}]}]]},"should match full key selector"],[{"key0.key1.0": [[{key2: [{a:"value2"},{a: "dummy"},{b:20}]}]]},"should match with key<-->index selector"],[{"key0.key1.0.0": [{key2: [{a:"value2"},{a: "dummy"},{b:20}]}]},"should match with key<-->multi-index selector"],[{"key0.key1.0.0.key2": [{a:"value2"},{a: "dummy"},{b:20}]},"should match with key<-->multi-index<-->key selector"]];fixtures.forEach(function(f){varquery=f[0],msg=f[1];varresult=Mingo.find(data,query).all();console.log(_.isEqual(result,data)+"> "+msg);});console.log(">>>>>>>>>>>>> finish test 2 <<<<<<<<<<<<<");// output below/* #Test 1: matching deep nested objects false> should not match without array index selector to nested valuefalse> should not match without enough depth for array index selector to nested valuetrue> should match with full array index selector to deeply nested valuetrue> should match with array index selector to nested value at depth 1false> should match with full array index selector to nested valuetrue> should match without array index selector to nested value at depth 1false> should match shallow nested value with array index selector>>>>>>>>>>>>> finish test 1 <<<<<<<<<<<<<#Test 2: matching whole objects/Users/francis/workspace/mingo/mingo.js:505 throw new Error("Invalid query operator '" + operator + "' detected"); ^Error: Invalid query operator '0' detected at Object.Mingo.Query._processOperator (/Users/francis/workspace/mingo/mingo.js:505:15) at Object.Mingo.Query._compile (/Users/francis/workspace/mingo/mingo.js:493:22) at Object.Mingo.Query (/Users/francis/workspace/mingo/mingo.js:472:10) at Object.Mingo.find (/Users/francis/workspace/mingo/mingo.js:820:13) at /Users/francis/workspace/mingo/test/test.js:44:23 at Array.forEach (native) at Object.<anonymous> (/Users/francis/workspace/mingo/test/test.js:41:10) at Module._compile (module.js:456:26) at Object.Module._extensions..js (module.js:474:10) at Module.load (module.js:356:32)*/
Test 1 does not pass all equality checks
Test 2 throws an exception
Tested with Mingo@v0.8.
The text was updated successfully, but these errors were encountered:
kofrasa
changed the title
Incorrect matching of deeply nested values without array index in selectors
Incorrect matching of deeply nested values in arrays
Dec 2, 2016
kofrasa
changed the title
Incorrect matching of deeply nested values in arrays
Incorrect matching of deeply nested values and whole objects
Dec 3, 2016
From experiments, MongoDB only allows one level of nesting when matching values in an array without explicit indexes in the selector.
Matching whole object is also broken.
Tested with MongoDB@v3.2.5.
We currently do not handle these cases correctly. Using the sample data.
Test 1 does not pass all equality checks
Test 2 throws an exception
Tested with Mingo@v0.8.
The text was updated successfully, but these errors were encountered: