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): handle virtual populate underneath document array with justOne=true and sort set where 1 element has only 1 result #12815

Merged
merged 1 commit into from Dec 19, 2022

Conversation

vkarpov15
Copy link
Collaborator

Fix #12730
Re: #10552

Summary

Strange edge case related to our fix for #10552. Using resultOrder only works well if each element of resultOrder is a number. Which is if we're populating an array. But if we have arrays, which means we're populating a property under a document array, then newOrder[_resultOrder] = doc doesn't work. But unfortunately, resultOrder's values will be a number if there's only 1 result for that particular document array element. This PR works around that by using the "element under document array" behavior whenever there is an array value in resultOrder.

Examples

… justOne=true and sort set where 1 element has only 1 result

Fix #12730
Re: #10552
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 59e0da5 into master Dec 19, 2022
@vkarpov15 vkarpov15 changed the title fix(populate): handle virtual populate underneath document array withjustOne=true and sort set where 1 element has only 1 result fix(populate): handle virtual populate underneath document array with justOne=true and sort set where 1 element has only 1 result Dec 19, 2022
@vkarpov15 vkarpov15 deleted the vkarpov15/gh-12730 branch December 29, 2022 17:12
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