Skip to content

Commit

Permalink
fix(query): delete top-level _bsontype property in queries to preve…
Browse files Browse the repository at this point in the history
…nt silent empty queries

Backport fix for #8222
Fix #8241
  • Loading branch information
vkarpov15 committed Jul 12, 2020
1 parent 1db031c commit f88eb25
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/cast.js
Expand Up @@ -23,6 +23,12 @@ module.exports = function cast(schema, obj, options, context) {
throw new Error('Query filter must be an object, got an array ', util.inspect(obj));
}

// bson 1.x has the unfortunate tendency to remove filters that have a top-level
// `_bsontype` property. Should remove this when we upgrade to bson 4.x. See gh-8222
if (obj.hasOwnProperty('_bsontype')) {
delete obj._bsontype;
}

var paths = Object.keys(obj);
var i = paths.length;
var _keys;
Expand Down

0 comments on commit f88eb25

Please sign in to comment.