I have a Recipe content type that uses a multi-value field for ingredients lists. I was testing doing a search and replace on "avocado." This is the field content before:

and the field content after:

and the error that I received upon performing the search/replace:
Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'field_ingredients_value' at row 1: INSERT INTO "node__field_ingredients" ("entity_id", "revision_id", "bundle", "delta", "langcode", "field_ingredients_value") VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5); Array ( [:db_insert_placeholder_0] => 250016 [:db_insert_placeholder_1] => 2070781 [:db_insert_placeholder_2] => recipe [:db_insert_placeholder_3] => 0 [:db_insert_placeholder_4] => en [:db_insert_placeholder_5] => 6 medium sweet potatoes, 2 scallions, sliced thin, 1 cup shredded part-skim mozzarella or dairy-free mozzarella style shreds, 1 cup canned black beans, drained, rinsed, 2 tbsp. Parmesan, grated, or dairy-free Parmesan or nutritional yeast, 1/2 avocadoo, peeled, pitted, and diced, 1/2 cup salsa verde, Extra virgin olive oil ) in Drupal\Core\Entity\Sql\SqlContentEntityStorage->saveToDedicatedTables() (line 1403 of /var/www/html/docroot/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).
| Comment | File | Size | Author |
|---|---|---|---|
| Screenshot 2024-07-19 at 12.32.36 PM.png | 55.24 KB | bhogue | |
| Screenshot 2024-07-19 at 12.30.26 PM.png | 148.48 KB | bhogue |
Issue fork scanner-3462717
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
bhogue commentedComment #3
anybodyDefinitely a major issue, thanks for the report! @bhogue could you create a MR with a fix maybe?
Comment #4
bhogue commentedSorry, @anybody, I don't have the expertise to provide a fix for this particular issue.
Comment #5
smustgrave commentedComment #6
damienmckennaData corruption is a critical problem we must fix before releasing a stable v2 version.
Comment #7
damienmckennaIt would help to add test coverage for this.
Comment #8
damienmckennaI'm working on this.
Comment #10
damienmckennaI've added test coverage for multi-value fields, and sure enough the test fails. That's kinda catastrophic.
Comment #11
damienmckennaThis logic could use some refactoring: #3584659: Refactor replacement logic to use a method in Entity class
Comment #12
damienmckennaClarifying the problem.
Comment #13
damienmckennaThis also affects the search logic, it only checks the first value in in multi-value fields.
Comment #15
damienmckennaThis has been fixed for text fields, but work needs to be done to make the solution generic so that all field types work correctly; there will be work done to make v2.0 reliable, stay tuned for more.
Comment #17
damienmckenna