Skip to content

Commit

Permalink
Fixes #623 by properly parsing nested IN conditions during recursive …
Browse files Browse the repository at this point in the history
…where clause operations
  • Loading branch information
jamessimone committed Sep 25, 2024
1 parent f65ea35 commit e7587ae
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
9 changes: 9 additions & 0 deletions extra-tests/classes/RollupEvaluatorTests.cls
Original file line number Diff line number Diff line change
Expand Up @@ -1258,6 +1258,15 @@ private class RollupEvaluatorTests {
System.assertEquals(false, eval.matches(nonMatch3));
}

@IsTest
static void stripsExtraParantheticalStructures() {
String whereClause = '(Name IN (\'0-Current\', \'1-30 Days\', \'31-60 Days\')) AND Name IN (\'0-Current\', \'1-30 Days\', \'31-60 Days\')';

RollupEvaluator eval = new RollupEvaluator.WhereFieldEvaluator(whereClause, ContactPointConsent.SObjectType);

System.assertEquals(true, eval.matches(new ContactPointConsent(Name = '0-Current')));
}

private static String getSoqlCompliantDatetime(Datetime dt) {
return dt.format('yyyy-MM-dd\'T\'HH:mm:ssZ');
}
Expand Down
9 changes: 8 additions & 1 deletion rollup/core/classes/RollupEvaluator.cls
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,14 @@ public without sharing abstract class RollupEvaluator implements Rollup.Evaluato
String value = words[++index];
if (criteria.endsWithIgnoreCase('in')) {
while (value.endsWith(')') == false) {
value += ' ' + words[++index];
String nextWord = words[++index];
value += ' ' + nextWord.removeEnd(')');
if (index + 1 == words.size()) {
break;
}
}
if (value.startsWith('(') && value.endsWith(')') == false) {
value += ')';
}
} else if (value.startsWith('\'') && value.endsWith('\'') == false) {
String tempVal = value;
Expand Down

0 comments on commit e7587ae

Please sign in to comment.