Skip to content

Commit

Permalink
Throw error when selector is array, fixes #4804
Browse files Browse the repository at this point in the history
  • Loading branch information
Sashko Stubailo committed Jul 29, 2015
1 parent ecaa7ff commit ad824aa
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/mongo/collection.js
Expand Up @@ -328,6 +328,12 @@ Mongo.Collection._rewriteSelector = function (selector) {
if (LocalCollection._selectorIsId(selector))
selector = {_id: selector};

if (_.isArray(selector)) {
// This is consistent with the Mongo console itself; if we don't do this
// check passing an empty array ends up selecting all items
throw new Error("Mongo selector can't be an array.");
}

if (!selector || (('_id' in selector) && !selector._id))
// can't match anything
return {_id: Random.id()};
Expand Down

0 comments on commit ad824aa

Please sign in to comment.