Skip to content

Commit

Permalink
Merge pull request #196 from paustint/fix-193
Browse files Browse the repository at this point in the history
Changed accessLevel property
  • Loading branch information
paustint authored Jun 21, 2022
2 parents f7b9def + f32c5e5 commit 0866573
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 14 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Changelog

## 4.5.0
## 4.5.0 / 4.5.1

June 21, 2022

Expand All @@ -9,6 +9,7 @@ June 21, 2022
- `SELECT Id FROM Account WITH USER_MODE`
- `SELECT Id FROM Account WITH SYSTEM_MODE`
- Thank you @ghingis
- Patch release - changed property from `accessLevel` to `withAccessLevel`

## 4.4.1

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -795,6 +795,7 @@ export interface QueryBase {
orderBy?: OrderByClause | OrderByClause[];
withDataCategory?: WithDataCategoryClause;
withSecurityEnforced?: boolean;
withAccessLevel?: boolean;
for?: ForClause;
update?: UpdateClause;
}
Expand Down
2 changes: 1 addition & 1 deletion src/api/api-models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ export interface QueryBase {
orderBy?: OrderByClause | OrderByClause[];
withDataCategory?: WithDataCategoryClause;
withSecurityEnforced?: boolean;
accessLevel?: AccessLevel;
withAccessLevel?: AccessLevel;
for?: ForClause;
update?: UpdateClause;
}
Expand Down
4 changes: 2 additions & 2 deletions src/composer/composer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,8 @@ export class Compose {
this.log(output);
}

if (query.accessLevel) {
output += this.formatter.formatClause(`WITH ${query.accessLevel}`);
if (query.withAccessLevel) {
output += this.formatter.formatClause(`WITH ${query.withAccessLevel}`);
this.log(output);
}

Expand Down
2 changes: 1 addition & 1 deletion src/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export interface ConditionExpressionContext {

export interface WithClauseContext {
withSecurityEnforced?: CstNode[];
accessLevel?: IToken[];
withAccessLevel?: IToken[];
withDataCategory?: CstNode[];
}

Expand Down
4 changes: 2 additions & 2 deletions src/parser/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -309,8 +309,8 @@ export class SoqlParser extends CstParser {
this.CONSUME(lexer.With);
this.OR([
{ ALT: () => this.CONSUME(lexer.SecurityEnforced, { LABEL: 'withSecurityEnforced' }) },
{ ALT: () => this.CONSUME(lexer.UserMode, { LABEL: 'accessLevel' }) },
{ ALT: () => this.CONSUME(lexer.SystemMode, { LABEL: 'accessLevel' }) },
{ ALT: () => this.CONSUME(lexer.UserMode, { LABEL: 'withAccessLevel' }) },
{ ALT: () => this.CONSUME(lexer.SystemMode, { LABEL: 'withAccessLevel' }) },
{ ALT: () => this.SUBRULE(this.withDataCategory) },
]);
});
Expand Down
10 changes: 5 additions & 5 deletions src/parser/visitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,12 +277,12 @@ class SOQLVisitor extends BaseSoqlVisitor {
ctx.withClause
.filter(item => !item.recoveredNode)
.forEach(item => {
const { withSecurityEnforced, accessLevel, withDataCategory } = this.visit(item);
const { withSecurityEnforced, withAccessLevel, withDataCategory } = this.visit(item);
if (withSecurityEnforced) {
query.withSecurityEnforced = withSecurityEnforced;
}
if (accessLevel) {
query.accessLevel = accessLevel;
if (withAccessLevel) {
query.withAccessLevel = withAccessLevel;
}
if (withDataCategory) {
query.withDataCategory = withDataCategory;
Expand Down Expand Up @@ -485,9 +485,9 @@ class SOQLVisitor extends BaseSoqlVisitor {
return {
withSecurityEnforced: true,
};
} else if (ctx.accessLevel) {
} else if (ctx.withAccessLevel) {
return {
accessLevel: ctx.accessLevel[0].image,
withAccessLevel: ctx.withAccessLevel[0].image,
};
} else {
return {
Expand Down
4 changes: 2 additions & 2 deletions test/test-cases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2503,7 +2503,7 @@ export const testCases: TestCase[] = [
output: {
fields: [{ type: 'Field', field: 'Id' }],
sObject: 'Account',
accessLevel: 'USER_MODE',
withAccessLevel: 'USER_MODE',
},
},
{
Expand All @@ -2512,7 +2512,7 @@ export const testCases: TestCase[] = [
output: {
fields: [{ type: 'Field', field: 'Id' }],
sObject: 'Account',
accessLevel: 'SYSTEM_MODE',
withAccessLevel: 'SYSTEM_MODE',
},
},
];
Expand Down

0 comments on commit 0866573

Please sign in to comment.