-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
Getters not applied in 3-level nested subdoc with toObject({ getters: true, virtuals: false })
in 8.5
#14840
Comments
Hi, thanks for the reproduction, Output mongoose Original Document: {
level1: {
level2: {
level3: {
property: 'testValue',
_id: new ObjectId('66cf7f8624943b65e0cdf3c2')
},
_id: new ObjectId('66cf7f8624943b65e0cdf3c1')
},
_id: new ObjectId('66cf7f8624943b65e0cdf3c0')
},
_id: new ObjectId('66cf7f8624943b65e0cdf3bf'),
__v: 0
}
Value TESTVALUE
With Getters Applied: {
_id: new ObjectId('66cf7f8624943b65e0cdf3bf'),
level1: {
level2: {
level3: {
property: 'TESTVALUE',
_id: new ObjectId('66cf7f8624943b65e0cdf3c2')
},
_id: new ObjectId('66cf7f8624943b65e0cdf3c1')
},
_id: new ObjectId('66cf7f8624943b65e0cdf3c0')
},
__v: 0
} Output mongoose Original Document: {
level1: {
level2: {
level3: {
property: 'testValue',
_id: new ObjectId('66cf80c5ef9ea412985c51c7')
},
_id: new ObjectId('66cf80c5ef9ea412985c51c6')
},
_id: new ObjectId('66cf80c5ef9ea412985c51c5')
},
_id: new ObjectId('66cf80c5ef9ea412985c51c4'),
__v: 0
}
Value TESTVALUE
With Getters Applied: {
_id: new ObjectId('66cf80c5ef9ea412985c51c4'),
level1: {
level2: {
level3: {
property: 'testValue',
_id: new ObjectId('66cf80c5ef9ea412985c51c7')
},
_id: new ObjectId('66cf80c5ef9ea412985c51c6')
},
_id: new ObjectId('66cf80c5ef9ea412985c51c5')
},
__v: 0
} |
We've done some digging and traced this to #14724, specifically the |
@vkarpov15 alright thank you :) |
fix(document): avoid unnecessary clone() in `applyGetters()` that was triggering additional getters
Prerequisites
Mongoose version
8.5.x
Node.js version
20.10.0
MongoDB server version
5.0.7
Typescript version (if applicable)
N/A
Description
Consider the following script:
In 8.4, the output would include
property: 'TEST VALUE'
uppercased. In 8.5, that no longer happens. See comments on #14728Steps to Reproduce
See above
Expected Behavior
getters applied
The text was updated successfully, but these errors were encountered: