Skip to content

fix: skip empty object write for untouched localized fields in mergeLocalizedData#16772

Open
deepshekhardas wants to merge 5 commits into
payloadcms:mainfrom
deepshekhardas:fix/16649-merge-localized-empty-object
Open

fix: skip empty object write for untouched localized fields in mergeLocalizedData#16772
deepshekhardas wants to merge 5 commits into
payloadcms:mainfrom
deepshekhardas:fix/16649-merge-localized-empty-object

Conversation

@deepshekhardas
Copy link
Copy Markdown
Contributor

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

  • Bug fix (non-breaking change which fixes an issue)

Developer and others added 5 commits May 19, 2026 09:45
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant