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(query): avoid executing transforms if query wasn't executed #13185

Merged
merged 3 commits into from Mar 21, 2023

Conversation

vkarpov15
Copy link
Collaborator

Fix #13165

Summary

Some of the refactoring we did to switch exec() to async/await created a quirk where we still execute query transforms even if the query errored out. This leads to odd consequences like throwing a DocumentNotFoundError if findOne() throws a cast error, even though Mongoose didn't execute a query.

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.

Is there any way we can write a test to prevent a regression in the future?

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.

LGTM, thanks! 👍

@vkarpov15 vkarpov15 merged commit 04786ca into master Mar 21, 2023
33 of 34 checks passed
@vkarpov15 vkarpov15 deleted the vkarpov15/gh-13165 branch March 21, 2023 14:58
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.

findById returns "DocumentNotFoundError" instead of "CastError" with invalid ID
2 participants