Skip to content

Commit 51fc964

Browse files
authored
Merge pull request #60 from paustint/bug-59
The field Format fails if it is in a query #59
2 parents a4fa350 + 93f4928 commit 51fc964

File tree

4 files changed

+65
-2
lines changed

4 files changed

+65
-2
lines changed

debug/test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
var soqlParserJs = require('./lib');
22

3-
const query = `@`;
3+
const query = `SELECT Id, Format, Foo FROM Account`;
44
// const query = `
55
// SELECT Id, Name, FORMAT(Amount),
66
// (SELECT Quantity, ListPrice, PricebookEntry.UnitPrice, PricebookEntry.Name FROM OpportunityLineItems)

lib/SoqlListener.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ export class Listener implements SOQLListener {
464464
if (this.config.logging) {
465465
console.log('enterFunction_name:', ctx.text);
466466
}
467-
if (this.context.currentItem === 'field') {
467+
if (this.context.currentItem === 'field' && this.context.currentFieldFn) {
468468
if (!this.context.currentFieldFn.fn) {
469469
this.context.currentFieldFn.fn = ctx.text;
470470
}

test/TestCases.ts

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1675,5 +1675,63 @@ export const testCases: TestCase[] = [
16751675
},
16761676
},
16771677
},
1678+
{
1679+
testCase: 55,
1680+
soql:
1681+
'SELECT Id, CreatedById, CreatedDate, DefType, IsDeleted, Format, LastModifiedById, LastModifiedDate, AuraDefinitionBundleId, ManageableState, Source, SystemModstamp FROM AuraDefinition',
1682+
output: {
1683+
fields: [
1684+
{
1685+
type: 'Field',
1686+
field: 'Id',
1687+
},
1688+
{
1689+
type: 'Field',
1690+
field: 'CreatedById',
1691+
},
1692+
{
1693+
type: 'Field',
1694+
field: 'CreatedDate',
1695+
},
1696+
{
1697+
type: 'Field',
1698+
field: 'DefType',
1699+
},
1700+
{
1701+
type: 'Field',
1702+
field: 'IsDeleted',
1703+
},
1704+
{
1705+
type: 'Field',
1706+
field: 'Format',
1707+
},
1708+
{
1709+
type: 'Field',
1710+
field: 'LastModifiedById',
1711+
},
1712+
{
1713+
type: 'Field',
1714+
field: 'LastModifiedDate',
1715+
},
1716+
{
1717+
type: 'Field',
1718+
field: 'AuraDefinitionBundleId',
1719+
},
1720+
{
1721+
type: 'Field',
1722+
field: 'ManageableState',
1723+
},
1724+
{
1725+
type: 'Field',
1726+
field: 'Source',
1727+
},
1728+
{
1729+
type: 'Field',
1730+
field: 'SystemModstamp',
1731+
},
1732+
],
1733+
sObject: 'AuraDefinition',
1734+
},
1735+
},
16781736
];
16791737
export default testCases;

test/TestCasesForIsValid.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,5 +150,10 @@ export const testCases: TestCaseForFormat[] = [
150150
soql: 'select some fake text',
151151
isValid: false,
152152
},
153+
{
154+
testCase: 30,
155+
soql: 'SELECT Id, Format FROM Account',
156+
isValid: true,
157+
},
153158
];
154159
export default testCases;

0 commit comments

Comments
 (0)