For an upsert, sf push can result in an "Integrity constraint violation" if Drupal thinks its creating, but it's actually updating.
Before saving a mapping object, sf push should check for existence of the sfid and update instead of create if it exists.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | salesforce-upsert_check_existing-2561209-1.patch | 801 bytes | aaronbauman |
Comments
Comment #2
aaronbaumanThis will get committed shortly unless I'm overlooking something that this will break.
Comment #3
aaronbaumanThis approach is too simplistic.
This patch was causing #2705597: When an upsert results in updating an existing SF record, and the existing SF record is already linked to a Drupal object, the new Drupal object does not get linked to anything
Comment #4
didebruSame error occurs within the 8.x and 5.x version.
SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'xxxxx' for key 'sfid__mapping'", class: "PDOException" }, message: "SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'xxx' for key 'sfid__mapping': INSERT INTO "salesforce_mapped_object" ("revision_id", "drupal_entity__target_id", "drupal_entity__target_type", "salesforce_mapping", "salesforce_id", "created", "changed", "entity_updated", "last_sync_status", "last_sync_action", "force_pull") 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, :db_insert_placeholder_8, :db_insert_placeholder_9, :db_insert_placeholder_10); Array ( [:db_insert_placeholder_0] => [:db_insert_placeholder_1] => xxx [:db_insert_placeholder_2] => xxx [:db_insert_placeholder_3] => xxx [:db_insert_placeholder_4] => xxx [:db_insert_placeholder_5] => xxx [:db_insert_placeholder_6] => xxx [:db_insert_placeholder_7] => xxxx [:db_insert_placeholder_8] => 1 [:db_insert_placeholder_9] => push_upsert [:db_insert_placeholder_10] => ) ", class: "Drupal\Core\Database\IntegrityConstraintViolationException" }, severity_level: 3 }, channel: "salesforce_mapped_object", message: "Drupal\Core\Database\IntegrityConstraintViolationException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'b2c_order_mapping-a1k7U0000007jIWQAY' for key 'sfid__mapping': INSERT INTO "salesforce_mapped_object" ("revision_id", "drupal_entity__target_id", "drupal_entity__target_type", "salesforce_mapping", "salesforce_id", "created", "changed", "entity_updated", "last_sync_status", "last_sync_action", "force_pull") 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, :db_insert_placeholder_8, :db_insert_placeholder_9, :db_insert_placeholder_10); Array ( [:db_insert_placeholder_0] => [:db_insert_placeholder_1] => xxx [:db_insert_placeholder_2] => xxxx [:db_insert_placeholder_3] => xxx [:db_insert_placeholder_4] => xxx [:db_insert_placeholder_5] => xxx [:db_insert_placeholder_6] => xxx [:db_insert_placeholder_7] => xxx [:db_insert_placeholder_8] => xxx [:db_insert_placeholder_9] => push_upsert [:db_insert_placeholder_10] => ) in Drupal\mysql\Driver\Database\mysql\ExceptionHandler->handleExecutionException() (line 50 of /app/yr7j26hzhz3v6/docroot/core/modules/mysql/src/Driver/Database/mysql/ExceptionHandler.php).", timestamp: "2022-11-15T22:43:03.380335+0100" }, http: { clientHost: "18.184.89.186", contentType: "application/json" } }Comment #5
gaurav.kapoor commentedDo we have any fix for this or any configuration related changes that can suppress this issue? Getting error on latest version compatible with D10.
Comment #6
bob.hinrichs commentedWe are getting a lot of these errors D10.3, latest version of salesforce suite. This issue would be in the fourth grade if it were a person :-)
Comment #7
aaronbauman7.x is no longer supported