Skip to content

Commit

Permalink
Update bolt.cls to account for IN ${LIST} syntax of db func
Browse files Browse the repository at this point in the history
  • Loading branch information
Edouard-Depret authored Jul 5, 2024
1 parent d8cbb12 commit 4a13d00
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions force-app/main/default/classes/Bolt.cls
Original file line number Diff line number Diff line change
@@ -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<String,Object> bindParams = (Map<String,Object>) JSON.deserializeUntyped(params);
// Map<String,Object> bindArrayArgs = (Map<String,Object>) JSON.deserializeUntyped(arrayArgs);
Map<String,Object> currentArrayArg = new Map<String, Object>();
for(String key : bindParams.keySet()){
String maybeArrayPayload = String.valueOf(bindParams.get(key));
if(maybeArrayPayload.startsWith(STARTS_WITH_ARRAY_TOKEN)){
currentArrayArg = (Map<String,Object>) JSON.deserializeUntyped(
maybeArrayPayload.replace(STARTS_WITH_ARRAY_TOKEN, '')
);
bindParams.put(key, currentArrayArg.keySet());
}
}
return Database.queryWithBinds(
query,
query,
bindParams,
level
);
}
}
}

0 comments on commit 4a13d00

Please sign in to comment.