From de9d28adccafefbd064da63de0eb76fa41bd98b0 Mon Sep 17 00:00:00 2001 From: David Glasser Date: Wed, 5 Mar 2014 12:29:54 -0800 Subject: [PATCH] Fix non-array fields with array fields --- packages/minimongo/minimongo_tests.js | 3 +++ packages/minimongo/sort.js | 6 ++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/minimongo/minimongo_tests.js b/packages/minimongo/minimongo_tests.js index 2e19809450..fe004e7843 100644 --- a/packages/minimongo/minimongo_tests.js +++ b/packages/minimongo/minimongo_tests.js @@ -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) { diff --git a/packages/minimongo/sort.js b/packages/minimongo/sort.js index 5c6936b588..49a62f9992 100644 --- a/packages/minimongo/sort.js +++ b/packages/minimongo/sort.js @@ -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) {