When adding multiple references of nodetype A to a single nodetype B the error below occured. Both nodetype A and nodetype B have link fields. When searching this error only one Google result showed: http://drupal.org/node/1290904. It was suggested to use field_attach_presave('node', $node); before field_attach_update('node', $node);
I found only one field_attach_update in the CNR code in function _corresponding_node_references_update(&$node). So I tried this solution. It works for me. But I have no idea why.

working code:

function _corresponding_node_references_update(&$node) {
  field_attach_presave('node', $node);
  field_attach_update('node', $node);
}

PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1: INSERT INTO {field_data_field_links} (entity_type, entity_id, revision_id, bundle, delta, language, field_links_url, field_links_title, field_links_attributes) 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, :db_insert_placeholder_7, ); Array ( [:db_insert_placeholder_0] => node [:db_insert_placeholder_1] => 12 [:db_insert_placeholder_2] => 12 [:db_insert_placeholder_3] => nodetypeB [:db_insert_placeholder_4] => 0 [:db_insert_placeholder_5] => und [:db_insert_placeholder_6] => www.foobar.com [:db_insert_placeholder_7] => ) in field_sql_storage_field_storage_write() (line 448 of /www/modules/field/modules/field_sql_storage/field_sql_storage.module).

Comments

Slaapmuts’s picture

Assigned: Slaapmuts » Unassigned

Accidentally assigned this to myself. Doh!

dilari’s picture

I can confirm it solves the issue I had (the same PDOException). Wheter this is the right way to fix it, I don't know.

hrodrig’s picture

I have this problem as well, but I can't seem to make your solution work.

Are you talking about modifying this function?

function corresponding_node_references_node_update($node) {
  corresponding_node_references_processing_node('update', $node);
}
markie’s picture

@Slaapmuts: Confirmed that you're fix works for me as well, however I too have no idea why.

@hrodrig: no, the function he is referencing is in the corresponding_node_references.crud.inc file.

In other news, this has apparently been applied to the dev branch.

justindodge’s picture

Status: Needs review » Reviewed & tested by the community

Fix in the initial issue description worked for me also (tested by downloading the latest dev release).

DamienMcKenna’s picture

Status: Reviewed & tested by the community » Active

Please don't change an issue to "Needs review" or "Reviewed and tested by the community" unless there's a patch.