fix: skip empty object write for untouched localized fields in mergeLocalizedData#16772
Open
deepshekhardas wants to merge 1 commit into
Open
Conversation
b70fcad to
d1e7a4f
Compare
d1e7a4f to
b738a4a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
When \mergeLocalizedData\ encounters untouched localized fields (fields that haven't been modified), it was writing empty objects {}\ into the database instead of skipping them entirely. This caused data loss in specific scenarios where partial updates were performed on localized documents.
Root Cause
The \mergeLocalizedData\ utility in the payload core was not checking if the incoming value for a localized field was an empty object before proceeding with the write. An empty object {}\ vs \undefined/null makes a difference in how the database handles the field - empty objects overwrite existing localized data.
Fix
Added a guard to skip writing when the incoming value for a localized field is an empty object {}. This ensures untouched fields retain their existing values.
Note
This PR was split from an earlier combined PR. The related fixes are now in separate PRs:
Type of change