-
-
Notifications
You must be signed in to change notification settings - Fork 4k
fix(bulkWrite): pass overwriteImmutable option to castUpdate fixes #15789
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
base: 7.x
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes issue #15781 by ensuring the overwriteImmutable option is properly propagated from bulkWrite operations through the casting pipeline to the handleImmutable function. This allows users to explicitly override immutable field protection when using bulkWrite operations, which was previously not possible.
Key Changes:
- Modified
handleImmutableto accept and respect theoverwriteImmutableoption - Updated
castUpdateto pass options through tohandleImmutablecalls - Modified
castBulkWriteto passoverwriteImmutablefrom operation options tocastUpdatefor both updateOne and updateMany operations
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| test/model.updateOne.test.js | Adds test case verifying that overwriteImmutable: true allows updating immutable createdAt field via bulkWrite |
| lib/helpers/query/handleImmutable.js | Adds options parameter to function signature and checks for options.overwriteImmutable to bypass immutable protection |
| lib/helpers/query/castUpdate.js | Updates both handleImmutable call sites to pass the options parameter |
| lib/helpers/model/castBulkWrite.js | Passes overwriteImmutable option from bulkWrite operations to castUpdate for updateOne and updateMany; also passes timestamps option to applyTimestampsToUpdate for granular timestamp control |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Tysm! |
AbdelrahmanHafez
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed that we can't use overwriteImmutable in TypeScript, pushing a fix for 7.x and master as well.
…ss of `timestamps` option
…without overwriteImmutable: true
…t matter when updating `createdAt` with `overwriteImmutable: true`
fix: allow timestamps and overwriteImmutable in TS and JS for 7.x
Fix #15781
Backport #15782 to 7.x
Summary
Examples