New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue when assigning values to nested fields #9459
Comments
Thank you for looking into this. This issue is due to Mongoose not handling nested paths within nested subdocs when setting a dotted path correctly, in either the v5.9.9 or the v5.10.10 behavior. The correct output is: User {
_id: 5f76e4b01dc7eacd204ab418,
email: 'foo@bar.com',
username: 'foobars',
preferences: { keepSession: true, notifications: { email: true } }
} Because you're explicitly setting In v5.10.8 we'll change it so that the output is |
Thank you very much quick reply. In our test suit we have a base object that we modified in each test depending on the conditions. What we expect is to merge the existing properties of the object The behaviour in version v5.9.9 and previous was perfect for us, and we expect to get the following:
Is there any workaround that we can implement to have this same result even in v5.10.8? |
Would it be possible for you to do: const userWithEmailNotifications = Object.assign({}, userFixture, {
'preferences.notifications.email': true
}) instead? |
Do you want to request a feature or report a bug?
Report a bug
What is the current behavior?
From v5.9.10 and later we have experienced a change in the behaviour when assigning a value to a nested property of a model. Let's take this script as an example:
The result is that no change is made to the nested property:
What is the expected behavior?
In v5.9.9 and previous versions the same code results in changing the property:
After looking for differences between v5.9.9 and v5.9.10 we have found that the issue is cause by the change in:
8fea1d9
This feels like a bug, though it may be intended behavior.
Could you please give us some clarification on the issue?
Thank you so much!
The text was updated successfully, but these errors were encountered: