Implemented dynamic SOSL
Pre-release
Pre-release
Dynamic SOSL has been implemented with minimal changes to how the framework is used.
- Added
ISObjectRespository.List<SObject> searchInAllFields(String searchTerm);
to require one basic SOSL method per object - Public methods can switch between using SOQL and SOSL by making 2 changes:
- Call the
getSearchQuery
method instead ofgetSearchQuery
. 2 parameters are expected, String searchTerm and SObjectRepository.SearchGroup searchGroup - Change
return (Lead)Database.query(query);
toreturn (Lead)Search.query(query)[0];
. This is because SOSL returns a list of lists, so we need to get the first list from the... list of lists (this seems silly to explain).
- Call the
- All other protected & private methods are shared between the SOQL & SOSL queries, with one exception:
SObjectRepository.setAsUpdate()
can be called, but is ignored for SOSL since SOSL does not support it. A debug statement with LoggingLevel.WARN will be shown in the logs in this situation.