When attempting to save a node with a CNR to another node with a CCK link field, I received the following error:

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_link} (entity_type, entity_id, revision_id, bundle, delta, language, field_link_url, field_link_title, field_link_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] => 7 [:db_insert_placeholder_2] => 7 [:db_insert_placeholder_3] => carousel_item [:db_insert_placeholder_4] => 0 [:db_insert_placeholder_5] => und [:db_insert_placeholder_6] => http://jamestkirk.com/ [:db_insert_placeholder_7] => ) in field_sql_storage_field_storage_write() (line 424 of /Users/acrollet/Sites/puam/www/modules/field/modules/field_sql_storage/field_sql_storage.module).

There is a related issue in the link queue: #1290904: Link > node_load() > field_attach_update() =PDOException: SQLSTATE[42000] INSERT INTO {field_data_field_link}. Adding a call to field_attach_presave before the field_attach_update in the _corresponding_node_references_update function fixed the issue. Will attach a patch.

CommentFileSizeAuthor
#1 add_field_attach_presave-1354816-1.patch503 bytesacrollet
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

acrollet’s picture

Status: Active » Needs review
FileSize
503 bytes

Patch attached.

apfelkraut.org’s picture

Same error here.

Using Drupal 7.9, References 7.x-2.0-beta3 and CNR 4.22, beside some others like Link 7.x-1.0.

I am using CNR to reference some different content types in a 1-unlimited relationship. Content types have also fields provided by the Link module. Did work fine the last months but I didn't need to create or update any relation lately. I applied the latest CNR update recently.

Today I added new content and tried to interrelate it to each other, I got the same error message like acrollet:

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_homepage} (entity_type, entity_id, revision_id, bundle, delta, language, field_homepage_url, field_homepage_title, field_homepage_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] => 677 [:db_insert_placeholder_2] => 2299 [:db_insert_placeholder_3] => serviceprovider [:db_insert_placeholder_4] => 0 [:db_insert_placeholder_5] => und [:db_insert_placeholder_6] => http://www.drupal.com/ [:db_insert_placeholder_7] => ) in field_sql_storage_field_storage_write() (line 448 of /home/mysite/public_html/sitename/modules/field/modules/field_sql_storage/field_sql_storage.module).

I deleted the content and created 2 new nodes, filled out some fields including URLs to outside Web pages but did not set any node relation. Saved nodes, everything fine. Edited nodes to add the relationship ... same error as given above.

Tried to test the patch. I updated References to 7.x-2.x-dev (2011-Oct-10), CNR to 7.x-4.x-dev (2011-Nov-17) and applied the provided patch so that my "corresponding_node_references.crud.inc" looks like

* @param $node the referenced node to be updated.
 */
function _corresponding_node_references_update(&$node) {
  field_attach_presave('node', $node);
  field_attach_update('node', $node);
}

I am still seeing the same error when creating a node relationship.

UPDATE (2011/12/06): Patch works also FINE with my site. Problem was that I patched the CNR module in directory "mysite/modules/" and had still an unpatched version in "mysite/sites/all/modules/" running. After I removed the unpatched version, the patched CNR modules works as expected and the error never appeared again. Thanks for the quick patch and sorry for the confusion!!

notasheep’s picture

Patch worked for me. Much thanks!

C. Lee’s picture

The patch in #1 solved the problem. Thanks.

bforchhammer’s picture

Status: Needs review » Reviewed & tested by the community

I guess this is RTBC: 3 people confirming that this works, and I can't see anything wrong with it either...

czigor’s picture

Status: Reviewed & tested by the community » Fixed

Committed.

Status: Fixed » Closed (fixed)

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

seehive’s picture

thanks... it works for me...
i was facing problem to apply this patch through command prompt so, i did this by coping the content of this patch and pasted it in "corresponding_node_references.crud.inc" and its working :). So, its simple way to apply patch i think

SGhosh’s picture

Worked for Version 7.x-4.22.