Implement .bulk_update(...)
See original GitHub issueThe method bulk_update is new in Django 2.2.
Implement it in Django-salesforce.
Notes: A method salesforce.dbapi.driver.RawConnection.sobject_collections_request(...)
was written for this purpose. The implementation in Django is completely different. Therefore we will not use any code from a Django method and easily backport it for Salesforce backend also to an old Django.
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
Bulk Update in Bulk Operations
The BulkUpdate method lets you update a large number of entities in your database. // easy to use bulk.DestinationTableName = "Customers"; bulk.
Read more >Bulk Update in EF Extensions (EFE)
The EF BulkUpdate extension method let you update a large number of entities in your database. // Easy to use context.BulkUpdate(customers); // Easy...
Read more >BulkUpdate - RepoDB
BulkUpdate. This method is used to update all the rows from the client application into the database by bulk. It is only supporting...
Read more >Performing Bulk Update - Telerik
Performing Bulk Update. The bulk update operation allows you to update data, based on filters expressed as LINQ queries, without loading it in...
Read more >bulkUpdate in sequelize orm - node.js - Stack Overflow
Use the bulkCreate to bulkUpdate method. bulkCreate([...], { updateOnDuplicate: ["name"] }). updateOnDuplicate is an array of fields that ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thanks for your interest and the offer. I can write some useful details: I think that the driver part with
cursor.db.connection.sobject_collections_request('PATCH', records)
has been worked correctly since v0.8.1. We should (and you can start it until you can) monkey paste the methodbulk_update
(source code) tosalesforce.backend.query.SalesforceQuerySet
. You see there a similarbulk_create
The problematic useless part in the originalbulk_update
is with CASE … WHEN … is here. Therefore we will not call it bysuper()
at all and useful parts like checks should be copied to our method.Also tests are useful also for understanding the SFDC API. I have test only for
bulk_create
intests.test_mock.test_data.test_create()
(I use “mocked” simplified recorded real responses of new SFDC API features that were documented with no or little examples because sometimes later after an new SFDC version it is easier for maintenance (if a problem is not found while in the release preview window). I think that e. g. error reporting with or without “allOrNone” has been changed in some/services/data/{API_VERSION}/composite/sobjects
and the change can not be verified because if even doesn’t depend on API_VERSION parameter but only the release.)It is still not clear what is the preferred way for django-salesforce users with handling of
allOrNone
parameter - that is similar to turn on transactions instead of autocommit. The batch size is 200 records for Salesforce. It is not possible to create a bigger “pseudo-transaction” than 200 records. It was also problematic, how to report succeeded / failed / cancelled updates to the end user if it is a mix (for records > 200). Maybe add a parameterall_or_none
to the method. Some people use SalesforceModels on sqlite for simple fast tests.So the minimal implementation is not too complicated, but there are many details and the final solution will require a discussion. Please can you start some work?
The queryset methods
.bulk_create(...)
,.update(...)
,.delete(...)
can be run with optionall_or_none
by the method.sf(all_or_none=True)
added somewhere before them in the queryset chain of a SalesforceModel.That works also with normal databases, where the option the option
all_or_none
is ignored. If a method.sf()
should exist in querysets for non-salesforce databases (e.g in tests) then theSalesforceModel
should be imported from modulesalesforce.models_extend
. That will be maybe a normal SalesforceModel, but currently it must be enabled explicitly by user that want it to can send a feedback continue with the old class until the new become generally acceptable.