-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move query & search execution back to SObjectRepository (#19)
* Created SOQLUtils class to handle parsing a List<Object> into the formatted expected by SOQL for each data type * Moved query & search execution back to SObjectRepository * Deleted some old classes
- Loading branch information
Showing
14 changed files
with
179 additions
and
336 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
public without sharing class SOQLUtils { | ||
|
||
public static String toSOQLString(List<Object> valueList) { | ||
List<String> parsedValueList = new List<String>(); | ||
for(Object value : valueList) parsedValueList.add(toSOQLString(value)); | ||
return '(' + String.join(parsedValueList, ',') + ')'; | ||
} | ||
|
||
public static String toSOQLString(Object value) { | ||
if(value == null) return null; | ||
else if(value instanceof Boolean) return String.valueOf((Boolean)value); | ||
else if(value instanceof Date) return String.valueOf((Date)value); | ||
else if(value instanceof Datetime) { | ||
Datetime datetimeValue = (Datetime)value; | ||
return datetimeValue.format('yyyy-MM-dd\'T\'HH:mm:ss\'Z\'', 'Greenwich Mean Time'); | ||
} | ||
else if(value instanceof Decimal) return String.valueOf((Decimal) value); | ||
else if(value instanceof Double) return String.valueOf((Double) value); | ||
else if(value instanceof Integer) return String.valueOf((Integer) value); | ||
else if(value instanceof Long) return String.valueOf((Long) value); | ||
else if(value instanceof SObject) { | ||
SObject record = (SObject)value; | ||
return wrapInSingleQuotes(record.Id); | ||
} | ||
else if(value instanceof String) return wrapInSingleQuotes((String)value); | ||
else return String.valueOf(value); | ||
} | ||
|
||
public static String wrapInSingleQuotes(String input) { | ||
if(input.left(1) != '\'') input = '\'' + input; | ||
if(input.right(1) != '\'') input = input + '\''; | ||
return input; | ||
} | ||
|
||
} |
File renamed without changes.
Oops, something went wrong.