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(populate): set populated docs in correct order when populating virtual underneath doc array with justOne #14105

Merged
merged 1 commit into from Nov 24, 2023

Conversation

vkarpov15
Copy link
Collaborator

Fix #14018

Summary

The issue is that Mongoose uses the sort order when assigning populated documents, which is incorrect in the case where you have virtual populate with justOne. In the justOne case, the sort just determines the documents you get back; the order in which the documents are assigned should be matched up by document id, not just using the sort order.

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.

LGTM

@vkarpov15 vkarpov15 merged commit 12c8bcd into master Nov 24, 2023
34 checks passed
vkarpov15 added a commit that referenced this pull request Nov 24, 2023
@vkarpov15 vkarpov15 added this to the 8.0.2 milestone Nov 24, 2023
@hasezoey hasezoey deleted the vkarpov15/gh-14018 branch November 24, 2023 16: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
2 participants