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

Feature/fix just one default #8125

Merged
merged 3 commits into from
Sep 4, 2019

Conversation

taxilian
Copy link
Contributor

@taxilian taxilian commented Sep 4, 2019

Thanks for submitting a pull request! Please provide enough information so that others can review your pull request. The two fields below are mandatory.

If you're making a change to documentation, do not modify a .html file directly. Instead find the corresponding .pug file or test case in the test/docs directory.

Summary

Commit a33c82e made a change to how PopulateOptions was constructed where all options were copied from the original; previously some options were only copied if they were truthy. The slightly weird result of this was a bug which causes a virtual populate field to fail to correctly default to justOne: false as it should.

I opted to just fix the place where it was treating the undefined value differently than a value not being present to minimize side effects.

Oddly enough it only seems to cause an issue if you're doing a lean query with a populate specifying specific subfields on a virtual field. shrug. This became a critical issue for us today so I tracked it down.

Examples

I added a unit test which can be used to reproduce the issue and verify the fix.

  - If the query is lean(), a field is selected in the populate, and
    the result only has one document it returns a single document
    instead of correctly returning a single document array�. This bug
    was introduced in commit a33c82e
Copy link
Collaborator

@vkarpov15 vkarpov15 left a comment

Choose a reason for hiding this comment

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

Thanks for finding this @taxilian , I'll push a release today.

@vkarpov15 vkarpov15 added this to the 5.6.13 milestone Sep 4, 2019
@vkarpov15 vkarpov15 merged commit 006a0f6 into Automattic:master Sep 4, 2019
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