Describe the bug
A clear and concise description of what the bug is.
To Reproduce
Query to find Permission Sets which contain a CustomPermission working in v5, breaks with v6.1. The last "AND ParentId != NULL" filter is added by the optimisation and is the culprit in this case.
SELECT Id FROM SetupEntityAccess WHERE (SetupEntityId IN (SELECT Id FROM CustomPermission WHERE (DeveloperName IN ('CustomPermissionName'))) AND Parent.IsOwnedByProfile = FALSE) AND ParentId != null
SOQL.of(SetupEntityAccess.SObjectType)
.whereAre(
SOQL.FilterGroup
.add(
SOQL.Filter.with(SetupEntityAccess.SetupEntityId)
.isIn(
SOQL.InnerJoin.of(CustomPermission.SObjectType)
.with(CustomPermission.Id)
.whereAre(
SOQL.FilterGroup.add(SOQL.Filter.with(CustomPermission.DeveloperName).isIn(customPermissions))
)
)
)
.add(SOQL.Filter.with('Parent', PermissionSet.IsOwnedByProfile).isFalse())
)
.systemMode()
.withoutSharing()
.mockId(MOCK_ID_GET_PERM_SETS)
.toMap(SetupEntityAccess.ParentId);
Expected behavior
Query should work, in some scenarios the key field used simply cannot be null. We should have an option to not "optimise". At least let's document a suitable workaround for these situations (not sure what it is yet - we are using toList for now and mapping in apex).
Describe the bug
A clear and concise description of what the bug is.
To Reproduce
Query to find Permission Sets which contain a CustomPermission working in v5, breaks with v6.1. The last "AND ParentId != NULL" filter is added by the optimisation and is the culprit in this case.
SELECT Id FROM SetupEntityAccess WHERE (SetupEntityId IN (SELECT Id FROM CustomPermission WHERE (DeveloperName IN ('CustomPermissionName'))) AND Parent.IsOwnedByProfile = FALSE) AND ParentId != nullExpected behavior
Query should work, in some scenarios the key field used simply cannot be null. We should have an option to not "optimise". At least let's document a suitable workaround for these situations (not sure what it is yet - we are using toList for now and mapping in apex).