-
-
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
Model.bulkWrite updateOne fails to update discriminator key with overwriteDiscriminatorKey set to true #15040
Comments
I have gotten the overwriteDiscriminatorKey option to work with Model.bulkWrite() updateOne with the following changes: mongoose/lib/helpers/model/castBulkWrite.js Lines 104 to 108 in f450083
mongoose/lib/helpers/model/castBulkWrite.js Lines 64 to 70 in f450083
mongoose/lib/helpers/model/castBulkWrite.js Lines 275 to 281 in f450083
Changes may be needed for other ops as well. |
The above changes determine the schema in a similar way to |
…ateOne and updateMany, allow inferring discriminator key from update Fix #15040
Prerequisites
Mongoose version
8.8.1
Node.js version
20.18.0
MongoDB server version
8.0.1
Typescript version (if applicable)
No response
Description
When updating the discriminator key in a document with schema discriminators, and setting the overwriteDiscriminatorKey option, the update succeeds when done with Model.updateOne() but fails when the same update is done by calling Model.bulkWrite() with the updateOne op.
Steps to Reproduce
The following script will fail to update the discriminator key:
However, if the call to bulkWrite() is replaced with updateOne() the operation will succeed:
Expected Behavior
Overwriting the discriminator key should succeed with Model.bulkWrite() as the same request does when done with Model.updateOne().
The text was updated successfully, but these errors were encountered: