Move $ne to the new model.

Fixes an expect_fail
This commit is contained in:
David Glasser
2013-12-27 22:25:25 -08:00
parent d243d30768
commit fdd16c6530
2 changed files with 17 additions and 13 deletions

View File

@@ -469,9 +469,6 @@ Tinytest.add("minimongo - selector_compiler", function (test) {
match({a: {$ne: {x: 1}}}, {a: {x: 1, y: 2}});
// This query means: All 'a.b' must be non-5, and some 'a.b' must be >6.
// Current bad code parses this as "All 'a.b' must be both non-5 and >6", so
// it doesn't allow for some 'a.b' to be <5.
test.expect_fail();
match({'a.b': {$ne: 5, $gt: 6}}, {a: [{b: 2}, {b: 10}]});
nomatch({'a.b': {$ne: 5, $gt: 6}}, {a: [{b: 2}, {b: 4}]});
nomatch({'a.b': {$ne: 5, $gt: 6}}, {a: [{b: 2}, {b: 5}]});

View File

@@ -228,19 +228,26 @@ var LOGICAL_OPERATORS = {
}
};
var invertBranchedSelector = function (branchedSelector) {
// Note that this implicitly "deMorganizes" the wrapped function. ie, it
// means that ALL branch values need to fail to match innerBranchedSelector.
return function (branchValues, doc) {
var invertMe = branchedSelector(branchValues, doc);
// We explicitly choose to strip arrayIndex here: it doesn't make sense to
// say "update the array element that does not match something", at least
// in mongo-land.
return {result: !invertMe.result};
};
};
// XXX doc
var VALUE_OPERATORS = {
$not: function (operand, operator, cursor) {
var innerBranchedSelector = compileValueSelector(operand, cursor);
// Note that this implicitly "deMorganizes" the wrapped function. ie, it
// means that ALL branch values need to fail to match innerBranchedSelector.
return function (branchValues, doc) {
var invertMe = innerBranchedSelector(branchValues, doc);
// We explicitly choose to strip arrayIndex here: it doesn't make sense to
// say "update the array element that does not match something", at least
// in mongo-land.
return {result: !invertMe.result};
};
return invertBranchedSelector(compileValueSelector(operand, cursor));
},
$ne: function (operand) {
return invertBranchedSelector(convertElementSelectorToBranchedSelector(
equalityElementSelector(operand)));
}
};