You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Error: `System.QueryException: Variable does not exist: v1`
10
+
11
+
### Root Cause
12
+
13
+
This is **NOT** the lib issue but rather a Salesforce platform limitation that occurs when `Database.getQueryLocatorWithBinds` is used with insufficient permissions.
14
+
15
+
This error occurs when all of the following conditions are met:
16
+
-`toQueryLocator()` is executed
17
+
- Query is executed with `USER_MODE` (which is the default mode if not otherwise specified)
18
+
- Query contains fields to which the user doesn't have access
19
+
- Query has at least one condition, which means that a binding map is used
Copy file name to clipboardExpand all lines: website/docs/advanced-usage/mocking.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,8 +4,8 @@ sidebar_position: 30
4
4
5
5
# Mocking
6
6
7
-
Mocking provides a way to substitute records from a Database with some prepared data. Data can be prepared in form of SObject records and lists in Apex code or Static Resource `.csv` file.
8
-
Mocked queries won't make any SOQL's and simply return data set in method definition, mock __will ignore all filters and relations__, what is returned depends __solely on data provided to the method__. Mocking is working __only during test execution__. To mock SOQL query, use `.mockId(id)` method to make it identifiable. If you mark more than one query with the same ID, all marked queries will return the same data.
7
+
Mocking provides a way to substitute records from a database with some prepared data. Data can be prepared in the form of SObject records and lists in Apex code or Static Resource `.csv` file.
8
+
Mocked queries won't make any SOQLs and simply return data set in method definition, mock __will ignore all filters and relations__, what is returned depends __solely on data provided to the method__. Mocking is working __only during test execution__. To mock SOQL query, use `.mockId(id)` method to make it identifiable. If you mark more than one query with the same ID, all marked queries will return the same data.
9
9
10
10
```apex title="ExampleController.cls"
11
11
public with sharing class ExampleController {
@@ -23,7 +23,7 @@ public with sharing class ExampleController {
23
23
}
24
24
```
25
25
26
-
Then in test simply pass data you want to get from Selector to `SOQL.mock(id).thenReturn(data)` method. Acceptable formats are: `List<SObject>` or `SObject`. Then during execution Selector will return desired data.
26
+
Then in tests simply pass data you want to get from Selector to `SOQL.mock(id).thenReturn(data)` method. Acceptable formats are: `List<SObject>` or `SObject`. Then during execution Selector will return the desired data.
Copy file name to clipboardExpand all lines: website/docs/docs/basic-features.md
+44-9Lines changed: 44 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -84,7 +84,7 @@ By default, all queries are executed `with sharing`, enforced by `AccessLevel.US
84
84
85
85
`AccessLevel.USER_MODE` enforces object permissions and field-level security.
86
86
87
-
Developer can skip FLS by adding `.systemMode()` and `.withSharing()`.
87
+
Developers can skip FLS by adding `.systemMode()` and `.withSharing()`.
88
88
89
89
```apex
90
90
// Query executed in without sharing
@@ -97,7 +97,7 @@ SOQL.of(Account.SObjectType)
97
97
98
98
### without sharing
99
99
100
-
Developer can control sharing rules by adding `.systemMode()` (record sharing rules are controlled by the sharingMode) and `.withoutSharing()`.
100
+
Developers can control sharing rules by adding `.systemMode()` (record sharing rules are controlled by the sharingMode) and `.withoutSharing()`.
101
101
102
102
```apex
103
103
// Query executed in with sharing
@@ -110,7 +110,7 @@ SOQL.of(Account.SObjectType)
110
110
111
111
### inherited sharing
112
112
113
-
Developer can control sharing rules by adding `.systemMode()` (record sharing rules are controlled by the sharingMode) by default it is `inherited sharing`.
113
+
Developers can control sharing rules by adding `.systemMode()` (record sharing rules are controlled by the sharingMode); by default it is `inherited sharing`.
114
114
115
115
```apex
116
116
// Query executed in inherited sharing
@@ -204,7 +204,7 @@ private class ExampleControllerTest {
204
204
205
205
### Count Result
206
206
207
-
```
207
+
```apex
208
208
@IsTest
209
209
private class ExampleControllerTest {
210
210
@@ -219,9 +219,39 @@ private class ExampleControllerTest {
219
219
}
220
220
```
221
221
222
+
### Aggregate Result
223
+
224
+
```apex
225
+
@IsTest
226
+
private class ExampleControllerTest {
227
+
228
+
@IsTest
229
+
static void getLeadSourceCounts() {
230
+
List<Map<String, Object>> aggregateResults = new List<Map<String, Object>>{
231
+
new Map<String, Object>{ 'LeadSource' => 'Web', 'total' => 10},
232
+
new Map<String, Object>{ 'LeadSource' => 'Phone', 'total' => 5},
233
+
new Map<String, Object>{ 'LeadSource' => 'Email', 'total' => 3}
0 commit comments