mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
Merge pull request #5968 from mitar/minimongo-elemmatch
Fixed $elemMatch with logical operators in Minimongo
This commit is contained in:
@@ -1135,6 +1135,12 @@ Tinytest.add("minimongo - selector_compiler", function (test) {
|
||||
{a: [{x: 1, b: 1}]});
|
||||
match({a: {$elemMatch: {$or: [{a: 1}, {b: 1}], x: 1}}},
|
||||
{a: [{x: 1, b: 1}]});
|
||||
match({a: {$elemMatch: {$or: [{a: 1}, {b: 1}]}}},
|
||||
{a: [{x: 1, b: 1}]});
|
||||
match({a: {$elemMatch: {$or: [{a: 1}, {b: 1}]}}},
|
||||
{a: [{x: 1, b: 1}]});
|
||||
match({a: {$elemMatch: {$and: [{b: 1}, {x: 1}]}}},
|
||||
{a: [{x: 1, b: 1}]});
|
||||
nomatch({a: {$elemMatch: {x: 1, $or: [{a: 1}, {b: 1}]}}},
|
||||
{a: [{b: 1}]});
|
||||
nomatch({a: {$elemMatch: {x: 1, $or: [{a: 1}, {b: 1}]}}},
|
||||
@@ -1142,6 +1148,15 @@ Tinytest.add("minimongo - selector_compiler", function (test) {
|
||||
nomatch({a: {$elemMatch: {x: 1, $or: [{a: 1}, {b: 1}]}}},
|
||||
{a: [{x: 1}, {b: 1}]});
|
||||
|
||||
test.throws(function () {
|
||||
match({a: {$elemMatch: {$gte: 1, $or: [{a: 1}, {b: 1}]}}},
|
||||
{a: [{x: 1, b: 1}]});
|
||||
});
|
||||
|
||||
test.throws(function () {
|
||||
match({x: {$elemMatch: {$and: [{$gt: 5, $lt: 9}]}}}, {x: [8]});
|
||||
});
|
||||
|
||||
// $comment
|
||||
match({a: 5, $comment: "asdf"}, {a: 5});
|
||||
nomatch({a: 6, $comment: "asdf"}, {a: 5});
|
||||
|
||||
@@ -681,7 +681,7 @@ ELEMENT_OPERATORS = {
|
||||
throw Error("$elemMatch need an object");
|
||||
|
||||
var subMatcher, isDocMatcher;
|
||||
if (isOperatorObject(operand, true)) {
|
||||
if (isOperatorObject(_.omit(operand, _.keys(LOGICAL_OPERATORS)), true)) {
|
||||
subMatcher = compileValueSelector(operand, matcher);
|
||||
isDocMatcher = false;
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user