Fix non-array fields with array fields

This commit is contained in:
David Glasser
2014-03-05 12:29:54 -08:00
parent bf32d79227
commit de9d28adcc
2 changed files with 7 additions and 2 deletions

View File

@@ -1814,6 +1814,9 @@ Tinytest.add("minimongo - sort keys", function (test) {
testKeys({'a.x': 1, 'a.y': 1},
{a: [{x: 0, y: 5}, {x: 1, y: 3}]},
[[0,5], [1,3]]);
testKeys({'a.x': 1, 'a.y': 1, b: -1},
{a: [{x: 0, y: 5}, {x: 1, y: 3}], b: 42},
[[0,5,42], [1,3,42]]);
});
Tinytest.add("minimongo - binary search", function (test) {

View File

@@ -189,8 +189,10 @@ _.extend(Minimongo.Sorter.prototype, {
});
if (knownPaths) {
// Similarly to above, paths must match everywhere.
if (_.size(knownPaths) !== _.size(valuesBySomething[whichField])) {
// Similarly to above, paths must match everywhere, unless this is a
// non-array field.
if (!_.has(valuesBySomething[whichField], '') &&
_.size(knownPaths) !== _.size(valuesBySomething[whichField])) {
throw Error("cannot index parallel arrays!");
}
} else if (usedPaths) {