The module fails to handle existing entities. For example, when I set up a new synchronization process for users, keyed by the username field, I get integrity constraint PDO errors on sync complaining that Salesforce_pull is trying to create users with duplicate 'name' values.
Attaching a patch which tries to failover intelligently. If salesforce_pull doesn't find an existing mapping record for a given salesforce object, it queries Drupal based on the salesforce key field. If Drupal has an existing entity with the correct value in the key field, we create a new salesforce mapping record.
Comments
Comment #1
ohthehugemanatee commentedComment #2
ohthehugemanatee commentedWow, I posted a duplicate of my own issue lol. Updating the patch here, and closing #2238875 .
Comment #3
aaronbaumanThis is definitely a problem, but the approach in this patch is not quite right.
I can see scenarios in which you would NOT want to automatically match existing entities.
Or where we want to match existing entities, but not on the same key we're using for upserts.
Lastly, this won't work for mappings which do not have any key.
Comment #4
bburgThis code seems a bit brittle, in that I'm running into situations, where $keyfield is not set, and errors like...
...are triggered as a result (I think). I tried wrapping that EFQ in the patch in a check that $keyfield exists. But my understanding of the problem/code at this point makes me feel like a monkey banging on it with a hammer. Also, doing the leads to what seems like several of the same record with only slightly different SalesForce IDs.
Comment #5
deivamagalhaes commentedI was having the same issue and was able to make it work by implementing hook_salesforce_pull_mapping_object_alter and creating the mapping object if there is a Drupal entity with the same value for the key field.
Comment #6
bburgMy issue in #4 was that somehow my mapping had been created without a key field actually set. Which shouldn't be possible as it is a required field. I'm not sure how that situation occurred (possibly Features?).
Comment #7
damienmckennaAt the very least the affected code has been changed since the patch was last written, so it needs to be rerolled.
Comment #8
damienmckennaFYI I'm not having this problem with the current codebase, but I am seeing it trying to create duplicate 'salesforce_mapping_object' records.
Comment #9
aaronbauman7.x is no longer supported