From 078b94102e18cfee85523ca4ae2071b5957bb417 Mon Sep 17 00:00:00 2001 From: Piotr Gajek Date: Tue, 30 Apr 2024 17:31:16 +0200 Subject: [PATCH] formattedString with null fix (#117) Signed-off-by: Piotr PG Gajek --- force-app/main/default/classes/SOQL.cls | 2 +- force-app/main/default/classes/SOQL_Test.cls | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) 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