Skip to content
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

fix(schema): avoid propagating toObject.transform and toJSON.transform option to implicitly created schemas #13634

Merged
merged 3 commits into from Jul 20, 2023

Conversation

vkarpov15
Copy link
Collaborator

Fix #13599

Summary

#13599 pointed out that we introduced a potentially breaking change in #13396: transform() option propagates to implicitly created schemas, which means existing transform functions need to account that they'll run on subdocuments. This PR undoes that backwards breaking change by explicitly omitting transform from the toJSON and toObject options propagated down to implicitly created schemas.

Examples

…form` option to implicitly created schemas

Fix #13599
Copy link
Collaborator

@hasezoey hasezoey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be reverted again for 8.0 as a breaking change?

test/document.test.js Outdated Show resolved Hide resolved
test/document.test.js Outdated Show resolved Hide resolved
vkarpov15 and others added 2 commits July 20, 2023 10:47
Co-authored-by: hasezoey <hasezoey@gmail.com>
Co-authored-by: hasezoey <hasezoey@gmail.com>
@vkarpov15
Copy link
Collaborator Author

I don't think we should revert this PR for 8.x. I think avoiding propagating transform down to implicitly created schemas is better UI design. Many transform functions are only relevant to the current schema, and not relevant to child schemas, so propagating transform causes more friction. The major benefit of propagating toObject and toJSON is propagating virtuals and getters.

@vkarpov15 vkarpov15 merged commit ef95e02 into master Jul 20, 2023
34 checks passed
@vkarpov15 vkarpov15 added this to the 7.4.1 milestone Jul 20, 2023
@hasezoey hasezoey deleted the vkarpov15/gh-13599 branch July 20, 2023 18:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

toJSON options gets passed to implicitly created schemas, including transform
2 participants