@@ -411,6 +411,7 @@ global virtual without sharing class RollupAsyncProcessor extends Rollup impleme
411
411
return System .enqueueJob (this );
412
412
}
413
413
414
+ @SuppressWarnings('PMD.ApexSOQLInjection')
414
415
protected override List <SObject > getExistingLookupItems (Set <String > objIds , RollupAsyncProcessor rollup , Set <String > uniqueQueryFieldNames ) {
415
416
if (objIds .isEmpty ()) {
416
417
return new List <SObject >();
@@ -433,7 +434,7 @@ global virtual without sharing class RollupAsyncProcessor extends Rollup impleme
433
434
new List <String >(uniqueQueryFieldNames ),
434
435
String .valueOf (rollup .lookupFieldOnLookupObject ),
435
436
' ='
436
- ) + ' \n FOR UPDATE' ;
437
+ ) + ( this . isSingleRecordSyncUpdate ( rollup ) ? ' \n FOR UPDATE' : ' ' ) ;
437
438
// non-obvious coupling between "objIds" and the computed "queryString", which uses dynamic variable binding
438
439
localLookupItems = Database .query (queryString );
439
440
}
@@ -925,8 +926,7 @@ global virtual without sharing class RollupAsyncProcessor extends Rollup impleme
925
926
rollup .rollupControl .ShouldRunAs__c == RollupMetaPicklists .ShouldRunAs .Synchronous ||
926
927
((hasExceededCurrentRollupLimits (rollup .rollupControl ) == false ) && isRunningAsync ) ||
927
928
System .isBatch () && Limits .getQueueableJobs () >= Limits .getLimitQueueableJobs () ||
928
- this .calcItems ?. size () == 1 &&
929
- (this .rollupControl .ShouldRunSingleRecordsSynchronously__c || rollup .rollupControl .ShouldRunSingleRecordsSynchronously__c );
929
+ this .isSingleRecordSyncUpdate (rollup );
930
930
931
931
if (rollup .rollupControl .ShouldAbortRun__c || this .rollupControl .ShouldAbortRun__c ) {
932
932
this .rollups .remove (index );
@@ -943,6 +943,11 @@ global virtual without sharing class RollupAsyncProcessor extends Rollup impleme
943
943
}
944
944
}
945
945
946
+ private Boolean isSingleRecordSyncUpdate (RollupAsyncProcessor roll ) {
947
+ return this .calcItems ?. size () == 1 &&
948
+ (this .rollupControl .ShouldRunSingleRecordsSynchronously__c || roll .rollupControl .ShouldRunSingleRecordsSynchronously__c );
949
+ }
950
+
946
951
private void overrideParentRollupControlValues (RollupControl__mdt specificControl ) {
947
952
// override section - most updates go from a rollup specific control -> this.rollupControl
948
953
if (specificControl .BatchChunkSize__c < this .rollupControl .BatchChunkSize__c ) {
0 commit comments