Skip to content

Commit 5162b48

Browse files
committed
Refactor context resolution logic and add integration tests for child relationships
1 parent 51162c0 commit 5162b48

File tree

6 files changed

+22
-9
lines changed

6 files changed

+22
-9
lines changed

docs/public/packages.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"packageId": "04tRb0000044fYYIA",
2+
"packageId": "04tRb0000045WPxIAM",
33
"componentPackageId": "04tRb0000012Mv8IAE"
44
}

expression-src/main/src/interpreter/ContextResolver.cls

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -272,11 +272,6 @@ public with sharing class ContextResolver implements Visitor {
272272
// References to @Context fields will always go to the top level query
273273
// as they are part of the global contextual context tied to the record Id
274274
// from which the Evaluation was started.
275-
276-
// TODO Add UT:
277-
// @Context.Contacts
278-
// -> WHERE(FirstName = "Georgina")
279-
280275
return addFieldToQuery(this.topLevelQuery, referenceName.toLowerCase());
281276
} else {
282277
this.queryContext.queryBuilder.selectField(referenceName);

sfdx-project.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"default": true
1414
},
1515
{
16-
"path": "unpackaged",
16+
"path": "unpackaged/integration-tests",
1717
"default": false
1818
}
1919
],

sfdx-project_packaging.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
{
44
"package": "Expression",
55
"versionName": "Version 1.36",
6-
"versionNumber": "1.47.0.NEXT",
6+
"versionNumber": "1.48.0.NEXT",
77
"path": "expression-src",
88
"default": false,
99
"versionDescription": "Expression core language",
@@ -76,6 +76,7 @@
7676
"Expression@1.44.0-1": "04tRb000003z0hJIAQ",
7777
"Expression@1.45.0-1": "04tRb0000042CNlIAM",
7878
"Expression@1.46.0-1": "04tRb000004400jIAA",
79-
"Expression@1.47.0-1": "04tRb0000044fYYIAY"
79+
"Expression@1.47.0-1": "04tRb0000044fYYIAY",
80+
"Expression@1.48.0-1": "04tRb0000045WPxIAM"
8081
}
8182
}

unpackaged/examples/integration-tests/classes/IntegrationTest.cls renamed to unpackaged/integration-tests/classes/IntegrationTest.cls

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,22 @@
11
@IsTest
22
private class IntegrationTest {
3+
@IsTest
4+
static void usingChildRelationships() {
5+
Account anyAccount = new Account(Name = 'Sample Account');
6+
insert anyAccount;
7+
Contact firstContact = new Contact(FirstName = 'First', LastName = 'Contact', AccountId = anyAccount.Id);
8+
Contact secondContact = new Contact(FirstName = 'Second', LastName = 'Contact', AccountId = anyAccount.Id);
9+
insert new List<Contact> { firstContact, secondContact };
10+
11+
String expressionPiped = '@Context.Contacts -> WHERE(FirstName = "First") -> SIZE() = 1';
12+
Boolean pipedResult = (Boolean)Evaluator.run(expressionPiped, anyAccount.Id);
13+
Assert.isTrue(pipedResult, 'There should be exactly one contact with the first name "First".');
14+
15+
String expressionNested = 'SIZE(WHERE(@Context.Contacts, FirstName = "First")) = 1';
16+
Boolean nestedResult = (Boolean)Evaluator.run(expressionNested, anyAccount.Id);
17+
Assert.isTrue(nestedResult, 'There should be exactly one contact with the first name "First".');
18+
}
19+
320
@IsTest
421
static void hasPurchasedSomethingInThePast() {
522
List<CustomRecordContext> contexts = getContexts();

unpackaged/examples/integration-tests/classes/IntegrationTest.cls-meta.xml renamed to unpackaged/integration-tests/classes/IntegrationTest.cls-meta.xml

File renamed without changes.

0 commit comments

Comments
 (0)