diff --git a/packages/minimongo/minimongo_tests.js b/packages/minimongo/minimongo_tests.js index 975cef503c..40aedf2c4b 100644 --- a/packages/minimongo/minimongo_tests.js +++ b/packages/minimongo/minimongo_tests.js @@ -2413,6 +2413,24 @@ Tinytest.add("minimongo - modifier affects selector", function (test) { {$and: [{ 'x.d': { $ne: 5, $gte: 433 } }, { 'a.b': 234 }]}] }, ['a.b', 'a.b.c', 'x.d'], 'group operators + duplicates'); + // When top-level value is an object, it is treated as a literal, + // so when you query col.find({ a: { foo: 1, bar: 2 } }) + // it doesn't mean you are looking for anything that has 'a.foo' to be 1 and + // 'a.bar' to be 2, instead you are looking for 'a' to be exatly that object + // with exatly that order of keys. { a: { foo: 1, bar: 2, baz: 3 } } wouldn't + // match it. That's why in this selector 'a' would be important key, not a.foo + // and a.bar. + testSelectorPaths({ + a: { + foo: 1, + bar: 2 + }, + 'b.c': { + literal: "object", + but: "we still observe any changes in 'b.c'" + } + }, ['a', 'b.c'], "literal object"); + function testSelectorAffectedByModifier (sel, mod, yes, desc) { if (yes) test.isTrue(LocalCollection._isSelectorAffectedByModifier(sel, mod, desc));