Skip to content

Commit f88eb25

Browse files
committed
fix(query): delete top-level _bsontype property in queries to prevent silent empty queries
Backport fix for #8222 Fix #8241
1 parent 1db031c commit f88eb25

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

lib/cast.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ module.exports = function cast(schema, obj, options, context) {
2323
throw new Error('Query filter must be an object, got an array ', util.inspect(obj));
2424
}
2525

26+
// bson 1.x has the unfortunate tendency to remove filters that have a top-level
27+
// `_bsontype` property. Should remove this when we upgrade to bson 4.x. See gh-8222
28+
if (obj.hasOwnProperty('_bsontype')) {
29+
delete obj._bsontype;
30+
}
31+
2632
var paths = Object.keys(obj);
2733
var i = paths.length;
2834
var _keys;

0 commit comments

Comments
 (0)