schema.recompileSchema exception when subDocument discriminator is defined before the model is compiled #14527
Closed
2 tasks done
Labels
confirmed-bug
We've confirmed this is a bug in Mongoose and will fix it.
Milestone
Prerequisites
Mongoose version
8.3.1
Node.js version
18.16
MongoDB server version
6.3.0
Typescript version (if applicable)
No response
Description
The following example throws "discriminator with name 'X' already exists" when the model of the top level schema is compiled after the discriminator definitions have been created on the subdocument schema.
If you create the model first, recompile seems to work as expected.
Important to note that on either case, the schema behaves as expected without recompiling.
Steps to Reproduce
Expected Behavior
The schema should recompile without error.
The text was updated successfully, but these errors were encountered: