(minimongo) Fix pull modifier not excepting null values

This commit is contained in:
DAB0mB
2015-09-25 19:18:00 +03:00
parent 90e5d3ea73
commit 96fc599455
2 changed files with 2 additions and 1 deletions

View File

@@ -2326,6 +2326,7 @@ Tinytest.add("minimongo - modify", function (test) {
modify({a: [2, 1, 2]}, {$pull: {a: 1}}, {a: [2, 2]});
modify({a: [2, 1, 2]}, {$pull: {a: 2}}, {a: [1]});
modify({a: [2, 1, 2]}, {$pull: {a: 3}}, {a: [2, 1, 2]});
modify({a: [1, null, 2, null]}, {$pull: {a: null}}, {a: [1, 2]});
modify({a: []}, {$pull: {a: 3}}, {a: []});
modify({a: [[2], [2, 1], [3]]}, {$pull: {a: [2, 1]}},
{a: [[2], [3]]}); // tested

View File

@@ -361,7 +361,7 @@ var MODIFIERS = {
throw MinimongoError("Cannot apply $pull/pullAll modifier to non-array");
else {
var out = [];
if (typeof arg === "object" && !(arg instanceof Array)) {
if (arg != null && typeof arg === "object" && !(arg instanceof Array)) {
// XXX would be much nicer to compile this once, rather than
// for each document we modify.. but usually we're not
// modifying that many documents, so we'll let it slide for