RE: Field TEXT can't accept \u0000 NULL value

thumbnail
Jamie Sammons, modified 1 Year ago. New Member Post: 1 Join Date: 4/15/20 Recent Posts

Database: Postgres 15

Liferay: DXP 7.4u92

Java class: com.liferay.dynamic.data.mapping.internal.upgrade.v4_1_0.DDMFieldUpgradeProcess

During migration, this class is utilized to separate the JSON data from DDMContent.data_ into DDMField and DDMFieldAttribute.

When DDMContent contains data_ like this:

{"availableLanguageIds":["it_IT"],"defaultLanguageId":"it_IT","fieldValues":[{"instanceId":"L4xqe9dP","name":"ClimateForcast_COMMENT","value":"File written by Adobe Photoshop  4.0\u0000"},{"instanceId":"nq3RkDSI","name":"HttpHeaders_CONTENT_TYPE","value":"image/jpeg"},{"instanceId":"Qbqjc3nB","name":"TIFF_BITS_PER_SAMPLE","value":"8"},{"instanceId":"kMOaW2J4","name":"TIFF_IMAGE_LENGTH","value":"3480"},{"instanceId":"uaqwPXo9","name":"TIFF_IMAGE_WIDTH","value":"2441"}]}

When attempting to insert DDMField and DDMFieldAttribute, the error occurred:

ERROR: invalid byte sequence for encoding "UTF8": 0x00_

In this case, it's important to escape these strings to ensure the migration proceeds without interruption. Alternatively, if this data is generated from existing documents in DL, it there the possibility to clear it before migration and regenerate it in the current Liferay version?

The workaround to complete the migration was:

update ddmcontent set data_ = regexp_replace(data_::text, '(?<!\\)\\u0000', '', 'g')::json

 

thumbnail
Jamie Sammons, modified 1 Year ago. Expert Posts: 367 Join Date: 9/5/14 Recent Posts

Bug Report Created: https://liferay.atlassian.net/browse/LPD-18801