Skip to content

Commit 078b941

Browse files
authored
formattedString with null fix (#117)
Signed-off-by: Piotr PG Gajek <[email protected]>
1 parent ac25ba2 commit 078b941

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

force-app/main/default/classes/SOQL.cls

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1494,7 +1494,7 @@ public virtual inherited sharing class SOQL implements Queryable {
14941494
}
14951495

14961496
private String formattedString(String value) {
1497-
return value ?? value.trim();
1497+
return value ?? value?.trim();
14981498
}
14991499

15001500
public Filter isIn(Iterable<Object> iterable) {

force-app/main/default/classes/SOQL_Test.cls

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1075,6 +1075,20 @@ private class SOQL_Test {
10751075
Assert.areEqual('%Test%', binding.get('v1'));
10761076
}
10771077

1078+
@IsTest
1079+
static void containsNull() {
1080+
// Test
1081+
SOQL builder = SOQL.of(Account.SObjectType)
1082+
.whereAre(SOQL.Filter.with(Account.Name).contains(null));
1083+
1084+
// Verify
1085+
String soql = builder.toString();
1086+
Assert.areEqual('SELECT Id FROM Account WHERE Name LIKE :v1', soql);
1087+
1088+
Map<String, Object> binding = builder.binding();
1089+
Assert.areEqual('%null%', binding.get('v1'));
1090+
}
1091+
10781092
@IsTest
10791093
static void notContains() {
10801094
// Test

0 commit comments

Comments
 (0)