Skip to content

Commit

Permalink
Merge pull request #51 from adangel/sosl-tolabel
Browse files Browse the repository at this point in the history
Support toLabel in SOSL queries
  • Loading branch information
pwrightcertinia authored Sep 2, 2024
2 parents 8522020 + e52b7ee commit aeb4b19
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
1 change: 1 addition & 0 deletions antlr/ApexParser.g4
Original file line number Diff line number Diff line change
Expand Up @@ -865,6 +865,7 @@ fieldSpec

fieldList
: soslId (COMMA fieldList)*
| TOLABEL LPAREN soslId RPAREN
;

updateList
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,12 @@ void testWithSystemModeQuery() {
assertNotNull(context);
assertEquals(0, parserAndCounter.getValue().getNumErrors());
}

@Test
void testToLabel() {
Map.Entry<ApexParser, SyntaxErrorCounter> parserAndCounter = createParser("[FIND :searchTerm IN ALL FIELDS RETURNING Account(Id, toLabel(Name)) LIMIT 10]");
ApexParser.SoslLiteralContext context = parserAndCounter.getKey().soslLiteral();
assertNotNull(context);
assertEquals(0, parserAndCounter.getValue().getNumErrors());
}
}
21 changes: 15 additions & 6 deletions npm/src/__tests__/SOSLParserTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,26 @@ test('testQuotesFailOnAltFormat', () => {
test('testWithUserModeQuery', () => {
const [parser, errorCounter] = createParser("[Find 'something' RETURNING Account WITH USER_MODE WITH METADATA='Labels']")

const context = parser.soslLiteralAlt()
const context = parser.soslLiteral()

expect(context).toBeInstanceOf(SoslLiteralAltContext)
expect(errorCounter.getNumErrors()).toEqual(1)
expect(context).toBeInstanceOf(SoslLiteralContext)
expect(errorCounter.getNumErrors()).toEqual(0)
})

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

const context = parser.soslLiteralAlt()
const context = parser.soslLiteral()

expect(context).toBeInstanceOf(SoslLiteralAltContext)
expect(errorCounter.getNumErrors()).toEqual(1)
expect(context).toBeInstanceOf(SoslLiteralContext)
expect(errorCounter.getNumErrors()).toEqual(0)
})

test('testToLabel', () => {
const [parser, errorCounter] = createParser("[FIND :searchTerm IN ALL FIELDS RETURNING Account(Id, toLabel(Name)) LIMIT 10]")

const context = parser.soslLiteral()

expect(context).toBeInstanceOf(SoslLiteralContext)
expect(errorCounter.getNumErrors()).toEqual(0)
})

0 comments on commit aeb4b19

Please sign in to comment.