Permalink
Browse files

Fixed a problem with deep object selectors with differing keys in min…

…imongo.

Select from minimongo would match objects who different in deep keys (not
values). It seems like the object matching of selector.js was intended to work
this way (the name `b_keys` implies that it should be the keys of `b` after
all), but was mis-implemented.

Fixes #455 - a subtle bug with almost-overlapping subscriptions

(glasser added another test case and cleaned up test whitespace.)
  • Loading branch information...
1 parent aaf5c63 commit c27941589c30ca1755f41ac4e1a63326d5a8f114 @tmeasday tmeasday committed with glasser Nov 5, 2012
Showing with 8 additions and 2 deletions.
  1. +4 −0 packages/minimongo/minimongo_tests.js
  2. +4 −2 packages/minimongo/selector.js
@@ -127,6 +127,10 @@ _.each(['observe', '_observeUnordered'], function (observeMethod) {
test.equal(c.find(undefined).count(), 0);
test.equal(c.find().count(), 3);
+ c.insert({foo: {bar: 'baz'}});
+ test.equal(c.find({foo: {bam: 'baz'}}).count(), 0);
+ test.equal(c.find({foo: {bar: 'baz'}}).count(), 1);
+
var ev = "";
var makecb = function (tag) {
return {
@@ -123,12 +123,14 @@ LocalCollection._f = {
// usually, but not for keys that parse as ints.)
var b_keys = [];
for (var x in b)
- b_keys.push(b[x]);
+ b_keys.push(x);
var i = 0;
for (var x in a) {
if (i >= b_keys.length)
return false;
- if (!match(a[x], b_keys[i]))
+ if (x !== b_keys[i])
+ return false;
+ if (!match(a[x], b[b_keys[i]]))
return false;
i++;
}

0 comments on commit c279415

Please sign in to comment.