Skip to content

Commit

Permalink
Fixes error reported interally with polymorphic where clause replacem…
Browse files Browse the repository at this point in the history
…ents being mutually exclusive with the current list of items
  • Loading branch information
jamessimone committed Oct 29, 2024
1 parent 2ea75e8 commit be50671
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
18 changes: 18 additions & 0 deletions extra-tests/classes/RollupCalcItemReplacerTests.cls
Original file line number Diff line number Diff line change
Expand Up @@ -177,4 +177,22 @@ private class RollupCalcItemReplacerTests {

System.assertEquals(ACC_ANNUAL_REVENUE, acc.AnnualRevenue);
}

@IsTest
static void exclusiveWhereClauseWithMultipleMetadataRecordsDoesNotBlowUpList() {
Account acc = [SELECT Id FROM Account];
RollupCalcItemReplacer replacer = new RollupCalcItemReplacer(
new RollupControl__mdt(IsRollupLoggingEnabled__c = true, ReplaceCalcItemsAsyncWhenOverCount__c = 3)
);

List<SObject> records = replacer.replace(
new List<Account>{ acc, acc },
new List<Rollup__mdt>{
new Rollup__mdt(CalcItemWhereClause__c = 'Id != \'' + acc.Id + '\' AND Owner.Name = null', CalcItem__c = 'Account'),
new Rollup__mdt(CalcItemWhereClause__c = 'AnnualRevenue = null', CalcItem__c = 'Account')
}
);

Assert.areEqual(0, records.size());
}
}
3 changes: 3 additions & 0 deletions rollup/core/classes/RollupCalcItemReplacer.cls
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,9 @@ public without sharing class RollupCalcItemReplacer {
Map<String, Schema.SObjectField> fieldMap = calcItems[0].getSObjectType().getDescribe(SObjectDescribeOptions.DEFERRED).fields.getMap();
for (Rollup__mdt meta : this.metaToEval.keySet()) {
calcItems = this.replaceCalcItemsWithPolymorphicWhereClauses(calcItems, meta, fieldMap);
if (calcItems.isEmpty()) {
break;
}
}
}
return calcItems;
Expand Down
4 changes: 2 additions & 2 deletions sfdx-project.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"package": "apex-rollup",
"path": "rollup",
"scopeProfiles": true,
"versionName": "Fixes Rollup Order By issue when called from RollupFlowBulkProcessor",
"versionNumber": "1.6.36.0",
"versionName": "Fixes mutually exclusive polymorphic where clauses replacing children in RollupCalcItemReplacer",
"versionNumber": "1.6.37.0",
"versionDescription": "Fast, configurable, elastically scaling custom rollup solution. Apex Invocable action, one-liner Apex trigger/CMDT-driven logic, and scheduled Apex-ready.",
"releaseNotesUrl": "https://github.com/jamessimone/apex-rollup/releases/latest",
"unpackagedMetadata": {
Expand Down

0 comments on commit be50671

Please sign in to comment.