Skip to content

Commit c64e02d

Browse files
committed
Fixes set-backed SOSL queries
1 parent 8a2109e commit c64e02d

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

force-app/repository/Query.cls

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ public virtual class Query {
212212
for (String key : this.bindVars.keySet()) {
213213
startingString = startingString.replace(':' + key, this.getSoslPredicate(this.bindVars.get(key)));
214214
}
215+
startingString = startingString.replaceAll('= \\(', 'IN \\(').replaceAll('!= \\(', 'NOT IN \\(');
215216
return startingString;
216217
}
217218

force-app/repository/RepositoryTests.cls

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,19 @@ private class RepositoryTests {
209209
System.assertEquals(cpa.Id, results.get(0).get(0).Id);
210210
}
211211

212+
@IsTest
213+
static void it_performs_sosl_set_backed_queries() {
214+
ContactPointAddress cpa = new ContactPointAddress(Name = 'hello world', PreferenceRank = 1);
215+
insert cpa;
216+
Test.setFixedSearchResults(new List<Id>{ cpa.Id });
217+
218+
List<List<SObject>> results = new ContactPointAddressRepo()
219+
.setSearchGroup(SearchGroup.NAME_FIELDS)
220+
.getSosl('hel', Query.equals(ContactPointAddress.PreferenceRank, new Set<Integer>{ 1, 2 }));
221+
222+
System.assertEquals(cpa.Id, results.get(0).get(0).Id);
223+
}
224+
212225
private class GroupMemberRepo extends Repository {
213226
public GroupMemberRepo() {
214227
super(GroupMember.SObjectType, new List<Schema.SObjectField>{ GroupMember.GroupId }, new RepoFactory());

0 commit comments

Comments
 (0)