Location records for nodes with a cck location field are not being created with values for nid, vid or uid. Also, the location_instance record is not being deleted when a node is deleted from the normal Drupal edit screen.

This is causing SQL created by views to fail miserably as is obvious in the SQL and data below. Here is the SQL from views as well as the output from a mysql session after creating a new node:

SELECT node.nid AS nid,
   node_data_field_tti_vendor_short_name.field_tti_vendor_short_name_value AS node_data_field_tti_vendor_short_name_field_tti_vendor_short_name_value,
   node.type AS node_type,
   node.vid AS node_vid,
   node.title AS node_title,
   location.lid AS location_lid,
   location.province AS location_province,
   location.country AS location_country
 FROM node node 
 LEFT JOIN content_type_tti_vendor node_data_field_tti_vendor_short_name ON node.vid = node_data_field_tti_vendor_short_name.vid
 LEFT JOIN location_instance location_instance ON node.vid = location_instance.vid
 LEFT JOIN location location ON location_instance.lid = location.lid


mysql> select * from content_type_tti_vendor;
+-----+-----+-----------------------------------+-------------------------------+
| vid | nid | field_tti_vendor_short_name_value | field_tti_vendor_location_lid |
+-----+-----+-----------------------------------+-------------------------------+
|   5 |   5 | ACS                               |                             4 | 
+-----+-----+-----------------------------------+-------------------------------+
1 row in set (0.00 sec)

mysql> select * from location_instance;
+-----+-----+-----+---------------------------------+-----+
| nid | vid | uid | genid                           | lid |
+-----+-----+-----+---------------------------------+-----+
|   0 |   0 |   0 | cck:field_tti_vendor_location:4 |   3 | 
|   0 |   0 |   0 | cck:field_tti_vendor_location:5 |   4 | 
+-----+-----+-----+---------------------------------+-----+
2 rows in set (0.00 sec)

This may be connected to http://drupal.org/node/373465 but I am not sure. I applied the simple fix from there to get rid of THAT error.

Comments

boftx’s picture

Component: Data update » Code
nickl’s picture

Status: Active » Closed (duplicate)

Patch ready to be reviewed which fixes this problem CCK/Views: location_instance fix