Skip to content

Commit

Permalink
formattedString with null fix (#117)
Browse files Browse the repository at this point in the history
Signed-off-by: Piotr PG Gajek <[email protected]>
  • Loading branch information
pgajek2 authored Apr 30, 2024
1 parent ac25ba2 commit 078b941
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion force-app/main/default/classes/SOQL.cls
Original file line number Diff line number Diff line change
Expand Up @@ -1494,7 +1494,7 @@ public virtual inherited sharing class SOQL implements Queryable {
}

private String formattedString(String value) {
return value ?? value.trim();
return value ?? value?.trim();
}

public Filter isIn(Iterable<Object> iterable) {
Expand Down
14 changes: 14 additions & 0 deletions force-app/main/default/classes/SOQL_Test.cls
Original file line number Diff line number Diff line change
Expand Up @@ -1075,6 +1075,20 @@ private class SOQL_Test {
Assert.areEqual('%Test%', binding.get('v1'));
}

@IsTest
static void containsNull() {
// Test
SOQL builder = SOQL.of(Account.SObjectType)
.whereAre(SOQL.Filter.with(Account.Name).contains(null));

// Verify
String soql = builder.toString();
Assert.areEqual('SELECT Id FROM Account WHERE Name LIKE :v1', soql);

Map<String, Object> binding = builder.binding();
Assert.areEqual('%null%', binding.get('v1'));
}

@IsTest
static void notContains() {
// Test
Expand Down

0 comments on commit 078b941

Please sign in to comment.