Version 5 changes how undefined value is handled compared to version 4 #8504
Labels
confirmed-bug
We've confirmed this is a bug in Mongoose and will fix it.
Milestone
Do you want to request a feature or report a bug?
Bug
What is the current behavior?
I have updated from mongoose mongoose@4.13.20 to mongoose@5.8.7, using mongo 3.4.20
I have noticed in version 5 when setting a value as undefined, it is saved as null.
In version 4 this would not have been set but ignored.
This happens when the minimize flag is set to false.
If the current behavior is a bug, please provide the steps to reproduce.
Output without minimize
Output with minimize
What is the expected behavior?
I expected the behavior to be the same in version 4 when using 5, in that undefined values are ignored, with or without the minimize flag.
What are the versions of Node.js, Mongoose and MongoDB you are using? Note that "latest" is not a version.
comments
In order to stop this, in mongoose 5 I have to set the minimize flag to true. Without this I end up saving documents with a load of null values, which will affect queries when using '$exists' operator.
Why has this changed? I can bypass it by setting minimize to true, but I'm unaware of the consequences.
The text was updated successfully, but these errors were encountered: