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: allow adding discriminators using Schema.prototype.discriminator() to subdocuments after defining parent schema #14131

Merged
merged 3 commits into from
Dec 1, 2023

Conversation

vkarpov15
Copy link
Collaborator

Fix #14109

Summary

For #14109, re: #13898. Delay applying discriminators added using Schema.prototype.discriminator() on embedded schemas (document arrays and single nested paths) until you compile the top-level model. This allows adding discriminators to document arrays using Schema.prototype.discriminator() after defining a document array with the schema, which is the primary issue in #14109.

Examples

…r()` to subdocuments after defining parent schema

Fix #14109
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.

Looks good to me, though there is one question:
the test define Class.type = number, but that field never seems to be used and does not match what is set in .discriminator(HERE, is this intentional?

@vkarpov15
Copy link
Collaborator Author

No, you're right that type doesn't do anything in the tests for #14109. I just copied that code from the person who reported the issue (adjusted for syntax). I removed the StringTyped.type = 4 etc. lines in 16e5308

@vkarpov15 vkarpov15 merged commit 42bf516 into 7.x Dec 1, 2023
42 checks passed
@hasezoey hasezoey deleted the vkarpov15/gh-14109 branch December 1, 2023 14:02
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.

None yet

2 participants