-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
ValidationError on setting null
on subdocument field after several other values being set
#14952
Closed
2 tasks done
Milestone
Comments
vkarpov15
added a commit
that referenced
this issue
Oct 17, 2024
fix(document): recursively clear modified subpaths when setting deeply nested subdoc to null
This was referenced Nov 9, 2024
This was referenced Nov 11, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Prerequisites
Mongoose version
8.7.1
Node.js version
21.6.2
MongoDB server version
8.0.0
Typescript version (if applicable)
5.4.5
Description
Fully working reproducible example
The following example leads into the following output:
Validation error because of `current.id` is required
Whereas If I change the
required
tofalse
on nested subdocs:then mongoose generates pretty absurd query, which tries to set both subdocuments and their parents to null:
Absurd output
But if you go and stop making two sets before setting to null, e.g.
Then output looks as expected:
Steps to Reproduce
Copy-paste the first code block from description.
Use the following
package.json
contents:Execute it via:
Expected Behavior
I'd expect that I can change the value of field which contains subdocument as many times I need, and after that set
null
within a single business transaction without validation errors on save.The text was updated successfully, but these errors were encountered: