Skip to content

Commit 85bf2c1

Browse files
committed
Small bug fixes #618
1 parent 1be5541 commit 85bf2c1

File tree

4 files changed

+34
-19
lines changed

4 files changed

+34
-19
lines changed

build/src/api/core/orgcheck-api-salesforcemanager-impl.js

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -343,21 +343,37 @@ export class SalesforceManager extends SalesforceManagerIntf {
343343
const allRecords = [];
344344
const indexOfFromStatment = query.indexOf(' FROM ');
345345
const indexOfGroupByStatment = query.indexOf(' GROUP BY ');
346-
const isWhereStatmentAlreadyUsed = query.indexOf(' WHERE ') !== -1;
346+
const isWhereStatmentAlreadyUsed = query.indexOf(' WHERE ') !== -1;
347+
const isOrderByStatmentAlreadyUsed = query.indexOf(' ORDER BY ') !== -1;
347348
const isAggregateQuery = indexOfGroupByStatment !== -1;
348-
// Make sure the field used for the queryMore is not used in the group by statement:
349-
if (isAggregateQuery && field && query.toLowerCase().indexOf(field.toLowerCase(), indexOfGroupByStatment) !== -1) {
350-
throw new SalesforceError(
351-
`The field <${field}> used for the custom queryMore cannot be used in the GROUP BY clause of the query <${query}>`,
352-
'CustomQueryMoreFieldInGroupBy',
353-
{
354-
'SoqlQuery': query ?? '(empty)',
355-
'Tooling': useTooling,
356-
'Field': field ?? '(empty)',
357-
'Cause': `Field used in GROUP BY`,
358-
'Where': 'SalesforceManagerImpl.soqlQuery/_customSOQLQuery'
359-
}
360-
);
349+
if (isAggregateQuery && field) {
350+
// Make sure the field used for the queryMore is not used in the group by statement:
351+
if (query.toLowerCase().indexOf(field.toLowerCase(), indexOfGroupByStatment) !== -1) {
352+
throw new SalesforceError(
353+
`The field <${field}> used for the custom queryMore cannot be used in the GROUP BY clause of the query <${query}>`,
354+
'CustomQueryMoreFieldInGroupBy',
355+
{
356+
'SoqlQuery': query ?? '(empty)',
357+
'Tooling': useTooling,
358+
'Field': field ?? '(empty)',
359+
'Cause': `Field used in GROUP BY`,
360+
'Where': 'SalesforceManagerImpl.soqlQuery/_customSOQLQuery'
361+
}
362+
);
363+
}
364+
// Make sure the initial query does not have ORDER BY statement as it is not needed at all when using custom queryMore:
365+
if (isOrderByStatmentAlreadyUsed) {
366+
throw new SalesforceError(
367+
`The query <${query}> is using an ORDER BY statement, which is not supported when using a custom queryMore`,
368+
'CustomQueryMoreWithOrderBy',
369+
{
370+
'SoqlQuery': query ?? '(empty)',
371+
'Tooling': useTooling,
372+
'Cause': `ORDER BY statement found`,
373+
'Where': 'SalesforceManagerImpl.soqlQuery/_customSOQLQuery'
374+
}
375+
);
376+
}
361377
}
362378
// Alternative method to queryMore based on ID ordering (inspired by Maroun IMAD!)
363379
const doNextQuery = async (/** @type {string} */ startingValue) => {

build/src/api/core/orgcheck-api-secretsauce.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -695,7 +695,7 @@ const ALL_SCORE_RULES = [
695695
description: 'User is logging directly without MFA',
696696
formula: (/** @type {SFDC_User} */ d) => d.nbDirectLoginsWithoutMFA > 0 && d.hasMfaByPass !== true,
697697
errorMessage: `This user is logging in directly to Salesforce without using MFA (Multi-Factor Authentication). And this user has not the MFA bypass enabled. Please work with your user to make them use MFA for better security.`,
698-
badField: 'nbDirectLoginWithoutMFA',
698+
badField: 'nbDirectLoginsWithoutMFA',
699699
applicable: [ SFDC_User ],
700700
category: SCORE_RULE_CATEGORIES.SECURITY
701701
}, {

build/src/api/dataset/orgcheck-api-dataset-apexclasses.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export class DatasetApexClasses extends Dataset {
7070
`WHERE ApexClassOrTriggerId IN (${subsetIds}) `+
7171
`AND ApexTestClass.ManageableState IN ('installedEditable', 'unmanaged') `+
7272
'GROUP BY ApexClassOrTriggerId, ApexTestClassId ',
73-
queryMoreField: 'CreatedDate',
73+
queryMoreField: 'CreatedDate',
7474
tooling: true
7575
});
7676
apexCodeCoverageAggQueries.push({

build/src/api/dataset/orgcheck-api-dataset-internalactiveusers.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,14 @@ export class DatasetInternalActiveUsers extends Dataset {
4141
string: 'SELECT UserId, Status, LoginType, COUNT(Id) CntLogins ' +
4242
'FROM LoginHistory ' +
4343
`WHERE (LoginType = 'Application' OR LoginType LIKE '%SSO%') ` + // the option 'queryMoreField' will add a final AND so that's why we have parenthesis here around the OR statement
44-
'GROUP BY UserId, Status, LoginType ' +
45-
'ORDER BY UserId, Status, LoginType ',
44+
'GROUP BY UserId, Status, LoginType ',
4645
queryMoreField: 'LoginTime' // aggregate does not support calling QueryMore, use the custom instead
4746
}, {
4847
string: 'SELECT UserId, Policy, COUNT(Id) CntVerifications ' +
4948
'FROM VerificationHistory ' +
5049
`WHERE Activity = 'Login' ` +
5150
`AND Status IN ('AutomatedSuccess', 'Succeeded') ` +
52-
`AND (LoginHistory.LoginType = 'Application')` +
51+
`AND (LoginHistory.LoginType = 'Application') ` +
5352
'GROUP BY UserId, Policy ',
5453
queryMoreField: 'VerificationTime' // aggregate does not support calling QueryMore, use the custom instead
5554
}], logger);

0 commit comments

Comments
 (0)