-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
Document.prototype.toObject() should run all getters on fields in subdocuments when getters option is set to true #14835
Labels
confirmed-bug
We've confirmed this is a bug in Mongoose and will fix it.
Milestone
Comments
vkarpov15
added
the
has repro script
There is a repro script, the Mongoose devs need to confirm that it reproduces the issue
label
Aug 28, 2024
Potentially the same issue as #14840 |
This seem to be the same issue I encountered, in my case it also started with mongoose >= 8.5.1 |
vkarpov15
added
confirmed-bug
We've confirmed this is a bug in Mongoose and will fix it.
and removed
has repro script
There is a repro script, the Mongoose devs need to confirm that it reproduces the issue
labels
Aug 29, 2024
This was referenced Sep 25, 2024
This was referenced Oct 3, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Prerequisites
Mongoose version
8.5.4
Node.js version
20.17.0
MongoDB server version
7.0.11
Typescript version (if applicable)
No response
Description
In versions 8.5.0 and prior, a call to Document.prototype.toObject() would run getters defined in schemas for subdocuments of arbitrary depth. In 8.5.1 and subsequent versions, toObject() will not run getters for subdocuments nested more than 1 level deep.
Getters should be run on all subdocument fields.
Steps to Reproduce
The following code will run the getters on field1 and field2 in mongoose versions 8.5.0 and prior, and will not run the getter for field2 in 8.5.1 and subsequent versions:
The above test will succeed on 8.5.0 and previous, and fail on 8.5.1 and subsequent versions.
Expected Behavior
All defined getters should be run for nested subdocuments.
The text was updated successfully, but these errors were encountered: