From a5cd5eb43542c35b92fefcfbb7bdd338205318b8 Mon Sep 17 00:00:00 2001 From: David Glasser Date: Tue, 31 Dec 2013 13:55:20 -0800 Subject: [PATCH] add comment about sort vs query --- packages/minimongo/sort.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/minimongo/sort.js b/packages/minimongo/sort.js index adc6708cee..dc2b838a5a 100644 --- a/packages/minimongo/sort.js +++ b/packages/minimongo/sort.js @@ -53,6 +53,13 @@ Sorter = function (spec) { // findMin). Each value can itself be an array, and we look at its values // too. (ie, we do a single level of flattening on branchValues, then find the // min/max.) + // + // XXX This is actually wrong! In fact, the whole attempt to compile sort + // functions independently of selectors is wrong. In MongoDB, if you have + // documents {_id: 'x', a: [1, 10]} and {_id: 'y', a: [5, 15]}, + // then C.find({}, {sort: {a: 1}}) puts x before y (1 comes before 5). + // But C.find({a: {$gt: 3}}, {sort: {a: 1}}) puts y before x (1 does not match + // the selector, and 5 comes before 10). var reduceValue = function (branchValues, findMin) { // Expand any leaf arrays that we find, and ignore those arrays themselves. branchValues = expandArraysInBranches(branchValues, true);