Skip to content

Commit

Permalink
bring in some changes from #14580
Browse files Browse the repository at this point in the history
  • Loading branch information
vkarpov15 committed May 24, 2024
1 parent 218d50a commit d4ad58e
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/query.js
Original file line number Diff line number Diff line change
Expand Up @@ -2416,14 +2416,20 @@ Query.prototype.merge = function(source) {
}

opts.omit = {};
if (this._conditions && Array.isArray(source.$and)) {
if (Array.isArray(source.$and)) {
opts.omit['$and'] = true;
if (!this._conditions) {
this._conditions = {};
}
this._conditions.$and = (this._conditions.$and || []).concat(
source.$and.map(el => utils.isPOJO(el) ? utils.merge({}, el) : el)
);
}
if (this._conditions && Array.isArray(source.$or)) {
if (Array.isArray(source.$or)) {
opts.omit['$or'] = true;
if (!this._conditions) {
this._conditions = {};
}
this._conditions.$or = (this._conditions.$or || []).concat(
source.$or.map(el => utils.isPOJO(el) ? utils.merge({}, el) : el)
);
Expand Down

0 comments on commit d4ad58e

Please sign in to comment.