force-dot-com-esapi icon indicating copy to clipboard operation
force-dot-com-esapi copied to clipboard

upsert operation

Open vinniks29 opened this issue 8 years ago • 2 comments

This is not an issue but a query. How can we test for upsert operation? I found method for insert/update and delete but not sure how to check for upsert

vinniks29 avatar Feb 01 '17 20:02 vinniks29

@vinniks29 We also needed upsert operation. We are working on implementing it. If possible we will send a pull request for this. :)

meajinkya avatar Oct 20 '17 05:10 meajinkya

I've implemented a custom version of upsert for ESAPI. One of the challenges way around how you define the whitelist of applicable fields to upsert.

I found that if the underlying operation turns into an insert you need to verify against one set of fields. In turn, if it is an update you need a different set of fields as some fields can only be inserted but not updated. It was a bit ugly, but I found I needed to pass through both sets of field names and then determine which to apply based on the ID being present.

However, that doesn't help you if you are upserting based on an external ID. How do you know if you are doing an insert or update without first checking if the record already exists?

FishOfPrey avatar Oct 28 '19 23:10 FishOfPrey