Add fflib_QueryFactory database operation mode support #434
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Goal
Add support for
USER_MODE
andSYSTEM_MODE
database operation modes to fflib_QueryFactory and fflib_SObjectSelector that provides backward compatibility with the existingenforceFLS
andenforceCRUD
checks.fflib_QueryFactory
When the operation mode is set, the
enforceFLS
is set to false to skip the fflib_SecurityUtils checks. Alternatively, when you callsetEnforceFLS(true)
, the operation mode is set to null, and fflib_SecurityUtils checks are respected.Operation Mode not set
Specify
WITH USER_MODE
Specify
WITH SYSTEM_MODE
Salesforce uses
SYSTEM_MODE
as the default operation mode when not specified in the query.withSystemMode()
allows users to make their queries explicit if desired.Works with other clauses
The `WITH {OPERATION_MODE}' clause is inserted after the WHERE clause and before any other clauses
Only applies to top-level queries
fflib_SObjectSelector
isEnforcingFLS()
andisEnforcingCRUD()
now consider the operation mode to determine their result instead of directly returning the values ofm_enforceFLS
andm_enforceCRUD
. This allows the user to get the correct state from the methods, regardless if they are using legacy enforcement or one of the new operation modes.When the operation mode is set, the
m_enforceFLS
andm_enforceCRUD
are false.Operation Mode not set
isEnforcingFLS()
andisEnforcingCRUD()
returns the value of the private properties. fflib_SecurityUtils checks are respected.Specify
USER_MODE
isEnforcingFLS()
andisEnforcingCRUD()
return true, but the properties are false. fflib_SecurityUtils checks are skipped.Specify
SYSTEM_MODE
isEnforcingFLS()
andisEnforcingCRUD()
return false, and the properties are set to false. fflib_SecurityUtils checks are skipped.Add
Enum fflib_SecurityUtils.OperationMode
fflib_QueryFactory
fflib_SObjectSelector
Change
fflib_QueryFactoryTest
fflib_SObjectSelector
m_enforceFLS
to use getter/setter so when its value is changed to true, then theoperationMode
property will be set to nullfflib_SObjectSelectorTest
This change is