-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update bolt.cls to account for IN ${LIST} syntax of db func
- Loading branch information
1 parent
d8cbb12
commit 4a13d00
Showing
1 changed file
with
15 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
); | ||
} | ||
} | ||
} |