Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions antlr/ApexLexer.g4
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,10 @@ NEXT_N_FISCAL_YEARS_N : 'next_n_fiscal_years';
LAST_N_FISCAL_YEARS_N : 'last_n_fiscal_years';
N_FISCAL_YEARS_AGO_N : 'n_fiscal_years_ago';

// SOQL Date literal
// SOQL Date and Time literals
DateLiteral: Digit Digit Digit Digit '-' Digit Digit '-' Digit Digit;
DateTimeLiteral: DateLiteral 't' Digit Digit ':' Digit Digit ':' Digit Digit ('z' | (('+' | '-') Digit+ ( ':' Digit+)? ));
TimeLiteral: Digit Digit ':' Digit Digit ':' Digit Digit ('.' Digit+ )? ('z' | (('+' | '-') Digit+ ( ':' Digit+)? ));
DateTimeLiteral: DateLiteral 't' TimeLiteral;

// SOQL Currency literal
// (NOTE: this is also a valid Identifier)
Expand Down
1 change: 1 addition & 0 deletions antlr/ApexParser.g4
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,7 @@ value
| signedNumber
| StringLiteral
| DateLiteral
| TimeLiteral
| DateTimeLiteral
| dateFormula
| IntegralCurrencyLiteral (DOT IntegerLiteral?)?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,4 +164,14 @@ void testFormatWithAggregate() {
assertNotNull(context);
assertEquals(0, parserAndCounter.getValue().getNumErrors());
}

@Test
void timeLiteral() {
Map.Entry<ApexParser, SyntaxErrorCounter> parserAndCounter = createParser(
"[SELECT Break__c,Check_Out__c FROM VMS_Time_Card_Item__c WHERE Time_Card__c =:timeCard.Id AND Check_Out__c = 01:00:00.000Z]"
);
ApexParser.SoqlLiteralContext context = parserAndCounter.getKey().soqlLiteral();
assertNotNull(context);
assertEquals(0, parserAndCounter.getValue().getNumErrors());
}
}
10 changes: 10 additions & 0 deletions npm/src/__tests__/SOQLParserTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,3 +172,13 @@ test("Format function with aggregate", () => {
expect(context).toBeInstanceOf(SoqlLiteralContext);
expect(errorCounter.getNumErrors()).toEqual(0);
});

test("Time Literal", () => {
const [parser, errorCounter] = createParser(
'[SELECT Break__c,Check_Out__c FROM VMS_Time_Card_Item__c WHERE Time_Card__c =:timeCard.Id AND Check_Out__c = 01:00:00.000Z]'
)
const context = parser.soqlLiteral();

expect(context).toBeInstanceOf(SoqlLiteralContext);
expect(errorCounter.getNumErrors()).toEqual(0);
});
Loading