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): recursively copy schemas from different modules when calling new Schema() #13441

Merged
merged 1 commit into from May 26, 2023

Conversation

vkarpov15
Copy link
Collaborator

Fix #13275

Summary

Right now, you can call new Schema() on a schema from a different copy of the Mongoose module to "copy" the schema over to use the local Mongoose module's schema class. But that doesn't apply to child schemas. This PR makes it so that child schemas also merge correctly.

Examples

Copy link
Collaborator

@AbdelrahmanHafez AbdelrahmanHafez left a comment

Choose a reason for hiding this comment

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

Can we have a test-case to prevent a future regression?

@vkarpov15
Copy link
Collaborator Author

Adding a test case for this is pretty difficult, and IMO not really worth the effort. We'd have to do some pretty sophisticated trickery to run a script that loads two copies of the Mongoose module without polluting require() in the actual test code.

Copy link
Collaborator

@IslandRhythms IslandRhythms left a comment

Choose a reason for hiding this comment

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

LGTM

@vkarpov15 vkarpov15 merged commit a29b45e into master May 26, 2023
33 of 34 checks passed
@vkarpov15 vkarpov15 deleted the vkarpov15/gh-13275 branch May 26, 2023 15:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants