-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
Discriminator Method Modifies Schema Argument in Mongoose #14821
Labels
confirmed-bug
We've confirmed this is a bug in Mongoose and will fix it.
Milestone
Comments
"Facing the same issue. The schema variable I pass to the discriminator method is being modified. While we can work around it by creating the discriminator like this:
the question remains: is it valid for the discriminator method to modify the argument, especially when it's a variable we're using?" |
facing the same issue |
vkarpov15
added
the
has repro script
There is a repro script, the Mongoose devs need to confirm that it reproduces the issue
label
Aug 21, 2024
vkarpov15
added
confirmed-bug
We've confirmed this is a bug in Mongoose and will fix it.
and removed
has repro script
There is a repro script, the Mongoose devs need to confirm that it reproduces the issue
labels
Aug 28, 2024
This was referenced Sep 19, 2024
This was referenced Sep 19, 2024
This was referenced Sep 25, 2024
This was referenced Sep 25, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Prerequisites
Mongoose version
7.2.2
Node.js version
20.12.2
MongoDB server version
7.0
Typescript version (if applicable)
No response
Description
When using Mongoose's discriminator method to create a new discriminator from a parent model, the method modifies the schema object passed as an argument. Specifically, it adds fields from the parent model's schema into the discriminator's schema, which is an unexpected and potentially invalid behavior.
Steps to Reproduce
Expected Behavior
Should the adminSchema remain unmodified after being passed to the discriminator method? We expect the fields from the userSchema to be combined with the adminSchema internally by Mongoose, without affecting the original schema object passed as an argument.
The text was updated successfully, but these errors were encountered: