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.

Comments

aaronbauman created an issue. See original summary.

aaronbauman’s picture

Status: Active » Needs review
StatusFileSize
new801 bytes

This will get committed shortly unless I'm overlooking something that this will break.

aaronbauman’s picture

didebru’s picture

Same 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" } }

gaurav.kapoor’s picture

Do we have any fix for this or any configuration related changes that can suppress this issue? Getting error on latest version compatible with D10.

bob.hinrichs’s picture

We 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 :-)

aaronbauman’s picture

Status: Needs work » Closed (won't fix)

7.x is no longer supported

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.