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(document): handle virtuals that are stored as objects but getter returns string with toJSON #14468

Merged
merged 1 commit into from Mar 30, 2024

Conversation

vkarpov15
Copy link
Collaborator

Fix #14446

Summary

#14446 points out that we continue to loop through and try to create properties when getting nested paths underneath a virtual even if the virtual returned a non-object. Since this will always throw an error, we should just avoid that and assume this is just the virtual returning a non-object by design.

Examples

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, aside from a slight test inconsistency

}));

const child = await ChildModel.create({ name: { en: 'Stephen', de: 'Stefan' } });
child.lang = 'en';
Copy link
Collaborator

Choose a reason for hiding this comment

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

from what i can tell lang is not actually part of the schema, is this required for this issue or should it be added?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think that's by design, it's meant to be a property that isn't saved to the db. Could make it into a virtual, but I don't think that's strictly necessary for this test.

@vkarpov15 vkarpov15 merged commit d3cb2ab into 6.x Mar 30, 2024
33 of 34 checks passed
@hasezoey hasezoey deleted the vkarpov15/gh-14446 branch March 30, 2024 11:59
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