From 4345fdbd4b8179fc52becfb32028d52bae4f3d4b Mon Sep 17 00:00:00 2001 From: Slava Kim Date: Fri, 13 Sep 2013 16:00:08 -0700 Subject: [PATCH] Always sort keys to simplify some cases. And don't modify the argument. --- packages/minimongo/minimongo.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/minimongo/minimongo.js b/packages/minimongo/minimongo.js index ec307a9507..75e5acd639 100644 --- a/packages/minimongo/minimongo.js +++ b/packages/minimongo/minimongo.js @@ -1038,12 +1038,12 @@ LocalCollection._compileProjection = function (fields) { throw MinimongoError("Projection values should be one of 1, 0, true, or false"); var _idProjection = _.isUndefined(fields._id) ? true : fields._id; - delete fields._id; + var fieldsKeys = _.reject(_.keys(fields).sort(), function (key) { return key === '_id'; }); var including = null; // Unknown var projectionRulesTree = {}; // Tree represented as nested objects - _.each(fields, function (rule, keyPath) { - rule = !!rule; + _.each(fieldsKeys, function (keyPath) { + var rule = !!fields[keyPath]; if (including === null) including = rule; if (including !== rule)