fix: skip empty object write for untouched localized fields in mergeLocalizedData#16772
Open
deepshekhardas wants to merge 5 commits into
Open
fix: skip empty object write for untouched localized fields in mergeLocalizedData#16772deepshekhardas wants to merge 5 commits into
deepshekhardas wants to merge 5 commits into
Conversation
The connectWithReconnect function calls pool.connect() to check out a client but never calls result.release() to return it to the pool. This permanently holds one connection from the pool, causing pool exhaustion when multiple concurrent queries are running. This fix adds result.release() after setting up the error listener to properly return the connection to the pool. Fixes: payloadcms#16256 (connection leak part)
…ectWithReconnect fix(db-postgres): fix connection leak in connectWithReconnect
The SAFE_STRING_REGEX was using \w which only matches ASCII characters,
blocking any non-ASCII characters (CJK, accented Latin, emoji, etc.) in
JSON field queries.
Changed to use \p{L} (Unicode letter) and \p{N} (Unicode number) with
the /u flag, which allows international text while still blocking SQL
metacharacters (' , ; -- ( ) = / \ etc.).
Fixes: payloadcms#16401
fix(drizzle): allow unicode characters in JSON query values
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.
Type of change