Story cck has a node reference field -> poll. All polls have been successfully migrated. When Story is being migrated, am getting the following exception:

SQLSTATE[HY000]: General error: 1366 Incorrect integer value: '' for column 'field_poll_target_id' at row 1: INSERT INTO {field_data_field_poll} (entity_type, entity_id, revision_id, bundle, delta, language, field_poll_target_id) 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] => 6776 [:db_insert_placeholder_2] => 6779 [:db_insert_placeholder_3] => story [:db_insert_placeholder_4] => 0 [:db_insert_placeholder_5] => und [:db_insert_placeholder_6] => )(/modules/field/modules/field_sql_storage/field_sql_storage.module:448)

The is the field mapping of the poll node:

$this->addFieldMapping('field_poll', 'field_poll_nid')
->sourceMigration(array(''))
->defaultValue(NULL);

Comments

mikeryan’s picture

Status: Active » Postponed (maintainer needs more info)

Try specifying the sourceMigration as the machine name of the poll migration - not an array, and not an empty string.

mikeryan’s picture

Version: » 7.x-2.x-dev
Priority: Major » Normal
Status: Postponed (maintainer needs more info) » Fixed

No further response.

tmetzger’s picture

I'm getting this too. I believe it's giving me one failure message for each time the "Story" node doesn't actually point to a "Poll" node (my nodes are actually different types, but the pattern is the same).

I've seen another thread where they suggested that the default value would take care of it, but that hasn't worked so far!

The field isn't required in the D6 source system or in the D7 destination system. Could this be a bug in the handler for node reference fields?

Let me add some detail. In my case "Song" refers to one or more "Composers". Here's my field mapping:

    $this->addFieldMapping('field_composer', 'field_composers')
         ->sourceMigration(array('Composer'))
         ->defaultValue(null);

and the error:

DOException: SQLSTATE[HY000]: General error: 1366 Incorrect integer value: '' for column 'field_composer_target_id' at row 1: INSERT INTO {field_data_field_composer} (entity_type, entity_id, revision_id, bundle, delta, language, field_composer_target_id) 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] => 8621 [:db_insert_placeholder_2] => 8621 [:db_insert_placeholder_3] => song [: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/groupanizer/domains/misc7/staging/modules/field/modules/field_sql_storage/field_sql_storage.module).

So as you can see it's trying to pass in a null value to an integer field...

Tom

peteruithoven’s picture

I just did a successful migration of a entity reference.

Let's say I had a couple of articles and people could add a reference to another article. I mapped it like this:

$this->addFieldMapping('field_based_on', 'field_derivative')
->sourceMigration('article');

"aricle" is the machine name of the same migration.

I'm amazed this is so simple.

tmetzger’s picture

Did it copy over all your records, or just the ones that had a reference?

tmetzger’s picture

Title: EntityReference field migration » SOLUTION

Hey guys,

In case anyone else finds this by searching, here's a tiny patch that fixes the underlying bug in migrate beautifully:
http://drupal.org/node/1805184

Cheers,
Tom

peteruithoven’s picture

Title: SOLUTION » EntityReference field migration

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Issue summary: View changes

slight edit