Skip to content

Commit d4ad58e

Browse files
committed
bring in some changes from #14580
1 parent 218d50a commit d4ad58e

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

lib/query.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2416,14 +2416,20 @@ Query.prototype.merge = function(source) {
24162416
}
24172417

24182418
opts.omit = {};
2419-
if (this._conditions && Array.isArray(source.$and)) {
2419+
if (Array.isArray(source.$and)) {
24202420
opts.omit['$and'] = true;
2421+
if (!this._conditions) {
2422+
this._conditions = {};
2423+
}
24212424
this._conditions.$and = (this._conditions.$and || []).concat(
24222425
source.$and.map(el => utils.isPOJO(el) ? utils.merge({}, el) : el)
24232426
);
24242427
}
2425-
if (this._conditions && Array.isArray(source.$or)) {
2428+
if (Array.isArray(source.$or)) {
24262429
opts.omit['$or'] = true;
2430+
if (!this._conditions) {
2431+
this._conditions = {};
2432+
}
24272433
this._conditions.$or = (this._conditions.$or || []).concat(
24282434
source.$or.map(el => utils.isPOJO(el) ? utils.merge({}, el) : el)
24292435
);

0 commit comments

Comments
 (0)