From 4a13d00339c7daadcbb39c716bcf46110d9b6f5f Mon Sep 17 00:00:00 2001 From: Edouard-Depret <89754705+Edouard-Depret@users.noreply.github.com> Date: Fri, 5 Jul 2024 16:21:26 +0200 Subject: [PATCH] Update bolt.cls to account for IN ${LIST} syntax of db func --- force-app/main/default/classes/Bolt.cls | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/force-app/main/default/classes/Bolt.cls b/force-app/main/default/classes/Bolt.cls index dc4fe37..7b1fa5b 100644 --- a/force-app/main/default/classes/Bolt.cls +++ b/force-app/main/default/classes/Bolt.cls @@ -1,12 +1,24 @@ public with sharing class Bolt { + public final static String STARTS_WITH_ARRAY_TOKEN = '$ARRAY$'; @AuraEnabled(cacheable=true) - public static Object[] soqlQuery(string query, String params, string mode) { + public static Object[] soqlQuery(String query, String params, String mode) { AccessLevel level = mode == 'WITH USER_MODE' ? AccessLevel.USER_MODE : AccessLevel.SYSTEM_MODE; Map bindParams = (Map) JSON.deserializeUntyped(params); + // Map bindArrayArgs = (Map) JSON.deserializeUntyped(arrayArgs); + Map currentArrayArg = new Map(); + for(String key : bindParams.keySet()){ + String maybeArrayPayload = String.valueOf(bindParams.get(key)); + if(maybeArrayPayload.startsWith(STARTS_WITH_ARRAY_TOKEN)){ + currentArrayArg = (Map) JSON.deserializeUntyped( + maybeArrayPayload.replace(STARTS_WITH_ARRAY_TOKEN, '') + ); + bindParams.put(key, currentArrayArg.keySet()); + } + } return Database.queryWithBinds( - query, + query, bindParams, level ); } -} \ No newline at end of file +}