Skip to content

Commit e52b7ee

Browse files
committed
Support toLabel in SOSL queries
1 parent fee3a16 commit e52b7ee

File tree

3 files changed

+24
-6
lines changed

3 files changed

+24
-6
lines changed

antlr/ApexParser.g4

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -864,6 +864,7 @@ fieldSpec
864864

865865
fieldList
866866
: soslId (COMMA fieldList)*
867+
| TOLABEL LPAREN soslId RPAREN
867868
;
868869

869870
updateList

jvm/src/test/java/io/github/apexdevtools/apexparser/SOSLParserTest.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,12 @@ void testWithSystemModeQuery() {
7676
assertNotNull(context);
7777
assertEquals(0, parserAndCounter.getValue().getNumErrors());
7878
}
79+
80+
@Test
81+
void testToLabel() {
82+
Map.Entry<ApexParser, SyntaxErrorCounter> parserAndCounter = createParser("[FIND :searchTerm IN ALL FIELDS RETURNING Account(Id, toLabel(Name)) LIMIT 10]");
83+
ApexParser.SoslLiteralContext context = parserAndCounter.getKey().soslLiteral();
84+
assertNotNull(context);
85+
assertEquals(0, parserAndCounter.getValue().getNumErrors());
86+
}
7987
}

npm/src/__tests__/SOSLParserTest.ts

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,17 +65,26 @@ test('testQuotesFailOnAltFormat', () => {
6565
test('testWithUserModeQuery', () => {
6666
const [parser, errorCounter] = createParser("[Find 'something' RETURNING Account WITH USER_MODE WITH METADATA='Labels']")
6767

68-
const context = parser.soslLiteralAlt()
68+
const context = parser.soslLiteral()
6969

70-
expect(context).toBeInstanceOf(SoslLiteralAltContext)
71-
expect(errorCounter.getNumErrors()).toEqual(1)
70+
expect(context).toBeInstanceOf(SoslLiteralContext)
71+
expect(errorCounter.getNumErrors()).toEqual(0)
7272
})
7373

7474
test('testWithSystemModeQuery', () => {
7575
const [parser, errorCounter] = createParser("[Find 'something' RETURNING Account WITH METADATA='Labels' WITH SYSTEM_MODE]")
7676

77-
const context = parser.soslLiteralAlt()
77+
const context = parser.soslLiteral()
7878

79-
expect(context).toBeInstanceOf(SoslLiteralAltContext)
80-
expect(errorCounter.getNumErrors()).toEqual(1)
79+
expect(context).toBeInstanceOf(SoslLiteralContext)
80+
expect(errorCounter.getNumErrors()).toEqual(0)
81+
})
82+
83+
test('testToLabel', () => {
84+
const [parser, errorCounter] = createParser("[FIND :searchTerm IN ALL FIELDS RETURNING Account(Id, toLabel(Name)) LIMIT 10]")
85+
86+
const context = parser.soslLiteral()
87+
88+
expect(context).toBeInstanceOf(SoslLiteralContext)
89+
expect(errorCounter.getNumErrors()).toEqual(0)
8190
})

0 commit comments

Comments
 (0)