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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(populate): allow deselecting discriminator key when populating #14155

Merged
merged 1 commit into from Dec 5, 2023

Conversation

vkarpov15
Copy link
Collaborator

Fix #3230
Re: #13760
Re: #13679

Summary

Right now, populating with __t: 0 in projection throws a "Cannot do inclusion on field prop in exclusion projection", whereas deselecting projection works fine outside of populate(). The issue looks to be an ordering issue: Mongoose isn't correctly handling __t: 0 as the first property in the select object, and with populate() Mongoose was reversing key order, so { name: 1, __t: 0 } was ending up as { __t: 0, name: 1 } because of utils.object.shallowCopy.

Both issues are fixed: Mongoose now handles __t: 0 as first property in select object (utils.object.shallowCopy() was removed, no longer necessary with spread operator), and populate() with { __t: 0 } now works as expected 馃憤

Examples

@vkarpov15 vkarpov15 added this to the 7.6.7 milestone Dec 5, 2023
@vkarpov15 vkarpov15 merged commit 2b93a2e into 7.x Dec 5, 2023
42 checks passed
@vkarpov15 vkarpov15 deleted the vkarpov15/gh-3230 branch December 5, 2023 18:39
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