The alter in 7002 will fail if any rows in any of the tables being altered have a NULL in the %_target_id column.

Ideally, I would like to see the user prompted to either delete the row, or allow the alter to continue, understanding that the NULL will be converted to 0.

The current fix is to manually run a query to fix the rows with NULL target_id's

If you go to /update.php part of the error message includes the "Alter Table" query that you can manually run to resolve the issue. Just delete the {}'s first and you can run it in a sql console.

entityreference module

Update #7002
Failed: PDOException: SQLSTATE[01000]: Warning: 1265 Data truncated for column 'field_common_user_target_id' at row 6: ALTER TABLE {field_data_field_common_user} CHANGE `field_common_user_target_id` `field_common_user_target_id` INT unsigned NOT NULL COMMENT 'The id of the target entity.'; Array ( ) in db_change_field() (line 2988 of /home/superman/git/myproj/includes/database/database.inc).

CommentFileSizeAuthor
#1 remove-null-entires-1821300-1.patch741 bytesStoraH
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

StoraH’s picture

Issue summary: View changes
FileSize
741 bytes

I know this issue is old but ran into this when I updated an old site. So here is a patch for the 7002 hook to also clean out NULL entries.

thechanceg’s picture

Patch from StoraH in #1 works as advertised.