Cannot override a non-required field from a base schema as of 5.12.7 #10203
Labels
confirmed-bug
We've confirmed this is a bug in Mongoose and will fix it.
has repro script
There is a repro script, the Mongoose devs need to confirm that it reproduces the issue
Milestone
Do you want to request a feature or report a bug?
Bug
What is the current behavior?
If I have a base schema that includes a field with required set to false and I add an additional schema to it which overrides that field to required set to true, this override stops working as of 5.12.7
If the current behavior is a bug, please provide the steps to reproduce.
Here is a script which reproduces the issue
What is the expected behavior?
Because we are NOT setting a username here, this should throw an error.
In versions before 5.12.7 this will error out with:
Starting with 5.12.7 though this now succeeds:
What are the versions of Node.js, Mongoose and MongoDB you are using? Note that "latest" is not a version.
Mongoose: 5.12.7
Node: v10.23.0
MongoDB: 4.2.13
The text was updated successfully, but these errors were encountered: