From 48eea25d272dd41ccb315d93574b2365aff09230 Mon Sep 17 00:00:00 2001 From: Slava Kim Date: Mon, 16 Sep 2013 11:04:08 -0700 Subject: [PATCH] Comments on keys sorting. Suggested by Glasser. --- packages/minimongo/minimongo.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/minimongo/minimongo.js b/packages/minimongo/minimongo.js index 75e5acd639..7fb03f7810 100644 --- a/packages/minimongo/minimongo.js +++ b/packages/minimongo/minimongo.js @@ -1038,6 +1038,9 @@ 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; + // Find the non-_id keys (_id is handled specially because it is included unless + // explicitly excluded). Sort the keys, so that our code to detect overlaps + // like 'foo' and 'foo.bar' can assume that 'foo' comes first. var fieldsKeys = _.reject(_.keys(fields).sort(), function (key) { return key === '_id'; }); var including = null; // Unknown var projectionRulesTree = {}; // Tree represented as nested objects