diff --git a/force-app/main/default/classes/SOQL.cls b/force-app/main/default/classes/SOQL.cls index 9052c84..b053da1 100644 --- a/force-app/main/default/classes/SOQL.cls +++ b/force-app/main/default/classes/SOQL.cls @@ -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 iterable) { diff --git a/force-app/main/default/classes/SOQL_Test.cls b/force-app/main/default/classes/SOQL_Test.cls index 286db3a..cacfe6e 100644 --- a/force-app/main/default/classes/SOQL_Test.cls +++ b/force-app/main/default/classes/SOQL_Test.cls @@ -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 binding = builder.binding(); + Assert.areEqual('%null%', binding.get('v1')); + } + @IsTest static void notContains() { // Test