Skip to content

Commit db9b813

Browse files
committed
v6.4.0
1 parent 2ac9091 commit db9b813

File tree

5 files changed

+178
-180
lines changed

5 files changed

+178
-180
lines changed

force-app/main/default/classes/cached-soql/SOQLCache.cls

Lines changed: 38 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,11 @@ global virtual inherited sharing class SOQLCache implements Cacheable {
7171
Object toValueOf(SObjectField fieldToExtract);
7272
}
7373

74-
protected virtual SOQL.Queryable initialQuery() {
74+
global virtual SOQL.Queryable initialQuery() {
7575
return null;
7676
}
7777

78-
protected virtual List<SObjectField> additionalAllowedConditionFields() {
78+
global virtual List<SObjectField> additionalAllowedConditionFields() {
7979
return new List<SObjectField>();
8080
}
8181

@@ -86,8 +86,7 @@ global virtual inherited sharing class SOQLCache implements Cacheable {
8686
void thenReturn(SObject record);
8787
}
8888

89-
@TestVisible
90-
private static Mockable mock(String mockId) {
89+
global static Mockable mock(String mockId) {
9190
if (!SOQLCache.queryIdToMock.containsKey(mockId)) {
9291
SOQLCache.queryIdToMock.put(mockId, new List<SoqlMock>());
9392
}
@@ -127,11 +126,11 @@ global virtual inherited sharing class SOQLCache implements Cacheable {
127126
private SOQL.Queryable initialQuery = null;
128127
private SOQL.Queryable currentQuery = null;
129128

130-
protected SOQLCache(SObjectType ofObject) {
129+
global SOQLCache(SObjectType ofObject) {
131130
this(ofObject.toString());
132131
}
133132

134-
protected SOQLCache(String ofObject) {
133+
global SOQLCache(String ofObject) {
135134
this.initialQuery = this.initialQuery()?.systemMode()?.withoutSharing();
136135
this.currentQuery = SOQL.of(ofObject).systemMode().withoutSharing();
137136

@@ -142,153 +141,153 @@ global virtual inherited sharing class SOQLCache implements Cacheable {
142141
this.with('Id');
143142
}
144143

145-
public Cacheable cacheInApexTransaction() {
144+
global Cacheable cacheInApexTransaction() {
146145
this.cache.storage.apexTransaction();
147146
return this;
148147
}
149148

150-
public Cacheable cacheInOrgCache() {
149+
global Cacheable cacheInOrgCache() {
151150
this.cache.storage.orgCache();
152151
return this;
153152
}
154153

155-
public Cacheable cacheInSessionCache() {
154+
global Cacheable cacheInSessionCache() {
156155
this.cache.storage.sessionCache();
157156
return this;
158157
}
159158

160-
public Cacheable maxHoursWithoutRefresh(Integer hours) {
159+
global Cacheable maxHoursWithoutRefresh(Integer hours) {
161160
this.cache.expiration.maxRecordAgeInHours(hours);
162161
return this;
163162
}
164163

165-
public Cacheable allowFilteringByNonUniqueFields() {
164+
global Cacheable allowFilteringByNonUniqueFields() {
166165
this.cache.filterGroup.allowFilteringByNonUniqueFields();
167166
return this;
168167
}
169168

170-
public Cacheable allowQueryWithoutConditions() {
169+
global Cacheable allowQueryWithoutConditions() {
171170
this.cache.filterGroup.allowQueryWithoutConditions();
172171
return this;
173172
}
174173

175-
public Cacheable with(SObjectField field) {
174+
global Cacheable with(SObjectField field) {
176175
this.initialQuery?.with(field);
177176
this.currentQuery.with(field);
178177
this.cache.fields.with(field);
179178
return this;
180179
}
181180

182-
public Cacheable with(SObjectField field1, SObjectField field2) {
181+
global Cacheable with(SObjectField field1, SObjectField field2) {
183182
return this.with(field1).with(field2);
184183
}
185184

186-
public Cacheable with(SObjectField field1, SObjectField field2, SObjectField field3) {
185+
global Cacheable with(SObjectField field1, SObjectField field2, SObjectField field3) {
187186
return this.with(field1, field2).with(field3);
188187
}
189188

190-
public Cacheable with(SObjectField field1, SObjectField field2, SObjectField field3, SObjectField field4) {
189+
global Cacheable with(SObjectField field1, SObjectField field2, SObjectField field3, SObjectField field4) {
191190
return this.with(field1, field2, field3).with(field4);
192191
}
193192

194-
public Cacheable with(SObjectField field1, SObjectField field2, SObjectField field3, SObjectField field4, SObjectField field5) {
193+
global Cacheable with(SObjectField field1, SObjectField field2, SObjectField field3, SObjectField field4, SObjectField field5) {
195194
return this.with(field1, field2, field3, field4).with(field5);
196195
}
197196

198-
public Cacheable with(List<SObjectField> fields) {
197+
global Cacheable with(List<SObjectField> fields) {
199198
this.initialQuery?.with(fields);
200199
this.currentQuery.with(fields);
201200
this.cache.fields.with(fields);
202201
return this;
203202
}
204203

205-
public Cacheable with(String fields) {
204+
global Cacheable with(String fields) {
206205
this.initialQuery?.with(fields);
207206
this.currentQuery.with(fields);
208207
this.cache.fields.with(fields);
209208
return this;
210209
}
211210

212-
public Cacheable with(String relationshipName, SObjectField field) {
211+
global Cacheable with(String relationshipName, SObjectField field) {
213212
this.initialQuery?.with(relationshipName, field);
214213
this.currentQuery.with(relationshipName, field);
215214
this.cache.fields.with(relationshipName, field);
216215
return this;
217216
}
218217

219-
public Cacheable with(String relationshipName, SObjectField field1, SObjectField field2) {
218+
global Cacheable with(String relationshipName, SObjectField field1, SObjectField field2) {
220219
return this.with(relationshipName, new List<SObjectField>{ field1, field2 });
221220
}
222221

223-
public Cacheable with(String relationshipName, SObjectField field1, SObjectField field2, SObjectField field3) {
222+
global Cacheable with(String relationshipName, SObjectField field1, SObjectField field2, SObjectField field3) {
224223
return this.with(relationshipName, new List<SObjectField>{ field1, field2, field3 });
225224
}
226225

227-
public Cacheable with(String relationshipName, SObjectField field1, SObjectField field2, SObjectField field3, SObjectField field4) {
226+
global Cacheable with(String relationshipName, SObjectField field1, SObjectField field2, SObjectField field3, SObjectField field4) {
228227
return this.with(relationshipName, new List<SObjectField>{ field1, field2, field3, field4 });
229228
}
230229

231-
public Cacheable with(String relationshipName, SObjectField field1, SObjectField field2, SObjectField field3, SObjectField field4, SObjectField field5) {
230+
global Cacheable with(String relationshipName, SObjectField field1, SObjectField field2, SObjectField field3, SObjectField field4, SObjectField field5) {
232231
return this.with(relationshipName, new List<SObjectField>{ field1, field2, field3, field4, field5 });
233232
}
234233

235-
public Cacheable with(String relationshipName, Iterable<SObjectField> fields) {
234+
global Cacheable with(String relationshipName, Iterable<SObjectField> fields) {
236235
this.initialQuery?.with(relationshipName, fields);
237236
this.currentQuery.with(relationshipName, fields);
238237
this.cache.fields.with(relationshipName, fields);
239238
return this;
240239
}
241240

242-
public Cacheable whereEqual(SObjectField field, Object value) {
241+
global Cacheable whereEqual(SObjectField field, Object value) {
243242
return this.whereEqual(field.toString(), value);
244243
}
245244

246-
public Cacheable whereEqual(String field, Object value) {
245+
global Cacheable whereEqual(String field, Object value) {
247246
this.with(field);
248247
this.cache.filterGroup.add(new CacheFilter().with(field).equal(value));
249248
this.currentQuery.whereAre(SOQL.Filter.with(field).equal(value));
250249
return this;
251250
}
252251

253-
public Cacheable stripInaccessible() {
252+
global Cacheable stripInaccessible() {
254253
return this.stripInaccessible(AccessType.READABLE);
255254
}
256255

257-
public Cacheable stripInaccessible(AccessType accessType) {
256+
global Cacheable stripInaccessible(AccessType accessType) {
258257
this.currentQuery.stripInaccessible(accessType);
259258
this.executor.stripInaccessible(accessType);
260259
return this;
261260
}
262261

263-
public Cacheable mockId(String queryIdentifier) {
262+
global Cacheable mockId(String queryIdentifier) {
264263
this.currentQuery.mockId(queryIdentifier);
265264
this.executor.mock(queryIdToMock.get(queryIdentifier));
266265
return this;
267266
}
268267

269-
public Cacheable preview() {
268+
global Cacheable preview() {
270269
this.currentQuery.preview();
271270
return this;
272271
}
273272

274-
public Id toId() {
273+
global Id toId() {
275274
return this.toObject()?.Id;
276275
}
277276

278-
public Id toIdOf(SObjectField field) {
277+
global Id toIdOf(SObjectField field) {
279278
return (Id) this.toObject()?.get(field);
280279
}
281280

282-
public Boolean doExist() {
281+
global Boolean doExist() {
283282
return this.toObject() != null;
284283
}
285284

286-
public Object toValueOf(SObjectField fieldToExtract) {
285+
global Object toValueOf(SObjectField fieldToExtract) {
287286
this.with(fieldToExtract);
288287
return this.toObject()?.get(fieldToExtract);
289288
}
290289

291-
public SObject toObject() {
290+
global SObject toObject() {
292291
this.cache.filterGroup.validateIfQueryHasAtLeastOneCondition();
293292
this.executeInitialQuery();
294293
return this.executor.toObject();
@@ -301,11 +300,11 @@ global virtual inherited sharing class SOQLCache implements Cacheable {
301300
this.cache.storage.putInitialRecordsToCache(this.initialQuery.toList());
302301
}
303302

304-
public Cacheable byId(SObject record) {
303+
global Cacheable byId(SObject record) {
305304
return byId(record.Id);
306305
}
307306

308-
public Cacheable byId(Id recordId) {
307+
global Cacheable byId(Id recordId) {
309308
whereEqual('Id', recordId);
310309
return this;
311310
}
@@ -761,4 +760,4 @@ global virtual inherited sharing class SOQLCache implements Cacheable {
761760
}
762761

763762
public class SoqlCacheException extends Exception {}
764-
}
763+
}

force-app/main/default/classes/soql-evaluator/SOQLEvaluator.cls

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@ global inherited sharing class SOQLEvaluator {
4646
Mockable thenReturn(List<SObject> records);
4747
}
4848

49-
@TestVisible
50-
private static Mockable mock(String mockId) {
49+
global static Mockable mock(String mockId) {
5150
if (!SOQLEvaluator.queryIdToMock.containsKey(mockId)) {
5251
SOQLEvaluator.queryIdToMock.put(mockId, new List<SoqlMock>());
5352
}

0 commit comments

Comments
 (0)