You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Oct 7, 2022. It is now read-only.
What steps will reproduce the problem?
1. Do a retrieve of 113 records by Id list.
2. It takes 2 minutes.
3. It took 113 API calls.
What is the expected output? What do you see instead?
The expected output is correct, but slow and expensive.
The attached code appears to product the same results, uses more memory,
but faster and less expensively.
def retrieve(
self,
fieldList,
sObjectType,
ids,
):
'''
Currently, this uses query() to emulate the retrieve() functionality, as suds' unmarshaller
borks on the sf: prefix that Salesforce prepends to all fields other than Id and type (any
fields not defined in the 'sObject' section of the Enterprise WSDL). This code used to
do a single API query for each Id. This was both slow and expensive.
'''
if len(ids) == 0:
return []
idsin = ["'%s'" % id for id in ids]
idsin = ",".join(idsin)
idsin = "(%s)" % idsin
sObjects = []
queryString = 'SELECT Id, ' + fieldList + ' FROM ' \
+ sObjectType + ' WHERE Id in %s ' % idsin
queryResult = self.query(queryString)
resultsById = {}
for record in queryResult.records:
if record:
sObject = self.generateObject(sObjectType)
for (k, v) in record:
setattr(sObject, k, v)
resultsById[sObject.Id] = sObject
for id in ids:
sObject = resultsById.get(id, None)
if sObject:
sObjects.append(sObject)
else:
sObjects.append(None)
return self._handleResultTyping(sObjects)
Original issue reported on code.google.com by sean.t...@gmail.com on 6 Jul 2011 at 2:48
The text was updated successfully, but these errors were encountered:
Original issue reported on code.google.com by
sean.t...@gmail.com
on 6 Jul 2011 at 2:48The text was updated successfully, but these errors were encountered: