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

Fix #8222
  • Loading branch information
vkarpov15 committed Oct 9, 2019
1 parent cc10e0d commit f3eca5b
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/cast.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,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;
}

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

0 comments on commit f3eca5b

Please sign in to comment.