I have migrated a site for D6 -> D7 and now when I attempt to save a node that has an optional node reference field without a value selected I get the following error.

PDOException: SQLSTATE[HY000]: General error: 1366 Incorrect integer value: '' for column 'field_res_contact_nid' at row 1: INSERT INTO {field_data_field_res_contact} (entity_type, entity_id, revision_id, bundle, delta, language, field_res_contact_nid) 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, :db_insert_placeholder_6); Array ( [:db_insert_placeholder_0] => node [:db_insert_placeholder_1] => 20553 [:db_insert_placeholder_2] => 29906 [:db_insert_placeholder_3] => level_3_6 [:db_insert_placeholder_4] => 0 [:db_insert_placeholder_5] => und [:db_insert_placeholder_6] => ) in field_sql_storage_field_storage_write() (line 448 of /home/alum/drupal-7.17/modules/field/modules/field_sql_storage/field_sql_storage.module).

This seems to be created by it not checking for the empty value and then attempting to insert it into an int field.

Comments

BWPanda’s picture

We had a very similar issue and the problem turned out to be that the content type's node reference field had an empty default value set...

Not sure how that happened, but re-saving the field settings form without a default value fixed it for us.

rhigginsME’s picture

Thanks!

Alex Andrascu’s picture

Priority: Major » Minor
Status: Active » Postponed (maintainer needs more info)
freakalis’s picture

I also had the same error after upgradeing an installation from Drupal 6. Resaving the field solved my error. Thank you!