Skip to content

dataCategoryName closes parenthesized data category list with LPAREN instead of RPAREN #141

Description

@rickroesler

Description

The dataCategoryName rule in antlr/BaseApexParser.g4 reads:

dataCategoryName
    : soqlId
    | LPAREN soqlId (COMMA soqlId)* LPAREN;

The second alternative opens the list with LPAREN but also closes it with LPAREN instead of RPAREN. As a result, valid multi-category WITH DATA CATEGORY filters fail to parse, while the never-valid form (usa__c, uk__c( would be accepted.

Reproduction

This query is taken verbatim from the Salesforce WITH DATA CATEGORY documentation:

SELECT Title FROM Question WHERE LastReplyDate > 2005-10-08T01:02:03Z WITH DATA CATEGORY Geography__c AT (usa__c, uk__c)

Parsing it with parser.query() (verified against v5.1.0, both npm and jvm targets) produces one syntax error at the closing ). Single-category filters (... AT usa__c) use the first alternative and are unaffected — likely why this has gone unnoticed.

Fix

One token: change the trailing LPAREN to RPAREN. I have the fix plus regression tests (the three doc examples, mirrored in both npm and jvm test suites) ready and will open a PR referencing this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions