You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If a field in a nested schema is of type array but is an empty field, {} is incorrectly added when doing a lean populate.
An empty array is added just fine in a normal populate, but in a lean populate an empty document is unexpectedly added, making the type inconsistent.
For consistent results, lean populate should be improved to not add it at all.
I want to fix it myself.
Prerequisites
Mongoose version
8.0.1
Node.js version
20.9.0
MongoDB server version
5.1
Typescript version (if applicable)
No response
Description
Ref: #8432
If a field in a nested schema is of type array but is an empty field,
{}
is incorrectly added when doing a lean populate.An empty array is added just fine in a normal populate, but in a lean populate an empty document is unexpectedly added, making the type inconsistent.
For consistent results, lean populate should be improved to not add it at all.
I want to fix it myself.
Steps to Reproduce
As you can see above, files is expected to be an array, but the {} is being added incorrectly, giving us the wrong result altogether.
Expected Behavior
The text was updated successfully, but these errors were encountered: