Skip to content

Commit

Permalink
fix: backport #14870 to 6.x
Browse files Browse the repository at this point in the history
  • Loading branch information
vkarpov15 committed Sep 10, 2024
1 parent fe17056 commit 9178805
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/document.js
Original file line number Diff line number Diff line change
Expand Up @@ -1224,7 +1224,7 @@ Document.prototype.$set = function $set(path, val, type, options) {
this.$__setValue(path, null);
cleanModifiedSubpaths(this, path);
} else {
return this.$set(val, path, constructing);
return this.$set(val, path, constructing, options);
}

const keys = getKeysInSchemaOrder(this.$__schema, val, path);
Expand Down
32 changes: 32 additions & 0 deletions test/document.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8078,6 +8078,38 @@ describe('document', function() {
await person.save();
});

it('set() merge option with double nested', async function () {

Check failure on line 8081 in test/document.test.js

View workflow job for this annotation

GitHub Actions / Lint JS-Files

Unexpected space before function parentheses

Check failure on line 8081 in test/document.test.js

View workflow job for this annotation

GitHub Actions / Lint JS-Files

Unexpected space before function parentheses
const PersonSchema = new Schema({
info: {
address: {
city: String,
country: { type: String, default: "UK" },

Check failure on line 8086 in test/document.test.js

View workflow job for this annotation

GitHub Actions / Lint JS-Files

Strings must use singlequote

Check failure on line 8086 in test/document.test.js

View workflow job for this annotation

GitHub Actions / Lint JS-Files

Strings must use singlequote
postcode: String
},

Check failure on line 8088 in test/document.test.js

View workflow job for this annotation

GitHub Actions / Lint JS-Files

Unexpected trailing comma

Check failure on line 8088 in test/document.test.js

View workflow job for this annotation

GitHub Actions / Lint JS-Files

Unexpected trailing comma
}
});

const Person = db.model('Person', PersonSchema);


const person = new Person({
info: {
address: {
country: "United States",

Check failure on line 8098 in test/document.test.js

View workflow job for this annotation

GitHub Actions / Lint JS-Files

Strings must use singlequote

Check failure on line 8098 in test/document.test.js

View workflow job for this annotation

GitHub Actions / Lint JS-Files

Strings must use singlequote
city: "New York"

Check failure on line 8099 in test/document.test.js

View workflow job for this annotation

GitHub Actions / Lint JS-Files

Strings must use singlequote

Check failure on line 8099 in test/document.test.js

View workflow job for this annotation

GitHub Actions / Lint JS-Files

Strings must use singlequote
},

Check failure on line 8100 in test/document.test.js

View workflow job for this annotation

GitHub Actions / Lint JS-Files

Unexpected trailing comma

Check failure on line 8100 in test/document.test.js

View workflow job for this annotation

GitHub Actions / Lint JS-Files

Unexpected trailing comma
}
});

const update = { info: { address: { postcode: "12H" } } };

Check failure on line 8104 in test/document.test.js

View workflow job for this annotation

GitHub Actions / Lint JS-Files

Strings must use singlequote

Check failure on line 8104 in test/document.test.js

View workflow job for this annotation

GitHub Actions / Lint JS-Files

Strings must use singlequote

person.set(update, undefined, { merge: true });

Check failure on line 8107 in test/document.test.js

View workflow job for this annotation

GitHub Actions / Lint JS-Files

Trailing spaces not allowed

Check failure on line 8107 in test/document.test.js

View workflow job for this annotation

GitHub Actions / Lint JS-Files

Trailing spaces not allowed
assert.equal(person.info.address.city, "New York");

Check failure on line 8108 in test/document.test.js

View workflow job for this annotation

GitHub Actions / Lint JS-Files

Strings must use singlequote

Check failure on line 8108 in test/document.test.js

View workflow job for this annotation

GitHub Actions / Lint JS-Files

Strings must use singlequote
assert.equal(person.info.address.postcode, "12H");

Check failure on line 8109 in test/document.test.js

View workflow job for this annotation

GitHub Actions / Lint JS-Files

Strings must use singlequote

Check failure on line 8109 in test/document.test.js

View workflow job for this annotation

GitHub Actions / Lint JS-Files

Strings must use singlequote
assert.equal(person.info.address.country, "United States");
});

it('setting single nested subdoc with timestamps (gh-8251)', async function() {
const ActivitySchema = Schema({ description: String }, { timestamps: true });
const RequestSchema = Schema({ activity: ActivitySchema });
Expand Down

0 comments on commit 9178805

Please sign in to comment.