Hello,
I think, I've found bug in using sf_node_nodeapi() hook.. The implemented hook "delete" will not work properly. Firstly, the drupal_type doesn't make sense, because it is always "node", secondly the quoting with "%s" doesn't work in postgres.. In line beginning 64:

    case 'delete':
      db_query('DELETE FROM {salesforce_object_map} WHERE drupal_type = "%s" AND oid = %d', 'node_'.$node->type, $account->uid);
      break;

I wrote:

    case 'delete':
    	  $salesforce = array('fieldmap' => null, 'sfid' => null);
	      $salesforce = salesforce_api_id_load('node', $node->nid);
	      db_query("DELETE FROM {salesforce_object_map} WHERE sfid = '%s' AND oid = %d", $salesforce['sfid'], $node->nid);
	    break;

Comments

AaronBauman’s picture

Thanks fragtom for bringing this up.
I was not aware that postgres choked on double quotes. I will try to eliminate them from the rest of the codebase as well.

Your other point, drupal_type is not always "node" - for sf_user mappings it's "user". in the case of uc_salesforce it's "order".
Consider the (albeit unlikely) scenario where a single Salesforce record is mapped to both a node and a user.
When the proposed hook_nodeapi::delete method is invoked, both the mapping to the node and the user are deleted.

Finally, this has all changed in the dev version of the module: delete functions have been moved into salesforce_api.module.
I can't say that it's definitely fixed, but it definitely works differently...

EvanDonovan’s picture

Status: Needs review » Active

"Needs review" status should only be used for issues that have a patch attached (see the issue queue handbook). I would recommend that you test the latest dev to see if it resolves the issue.

EvanDonovan’s picture

Aaron, should we re-purpose the issue to creating a patch (against dev) to remove the double quotes, or will you just handle that in your next code release?

AaronBauman’s picture

Title: Salesforce Node delete via nodeapi_hook() » Add Postgres support: Change double quotes to single quotes in database queries
Version: 6.x-2.0-alpha2 » 6.x-2.x-dev
Category: bug » task

Good idea.

I will also make a note of this on the project page.

EvanDonovan’s picture

Note that this issue doesn't apply on D7, since the database abstraction layer is different.

kostajh’s picture

Status: Active » Closed (won't fix)