Illuminated cloud not supporting TYPEOF SOQL queries properly

Issue #806 resolved
Michael Ebert created an issue

When defining a so called polymorphic SOQL query in a usual Apex class, Illuminated Cloud shows a syntax error with

',' expected, got 'WHEN'

Sample query:

SELECT Id, TYPEOF Owner
                          WHEN User THEN UserType
                        END,
                        CreatedBy.UserType
                   FROM Lead

The error only shows up in the IDE, the Apex class can be saved to the target org successfully anyway.

See https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_select_typeof.htm for a description of the TYPEOF syntax.

Comments (10)

  1. Scott Wells repo owner

    Thanks for filing, Michael. Should be a pretty simple grammar fix. I'll see about including it in a near-term build.

  2. Scott Wells repo owner

    Wow...I think this just got lost in the shuffle as it wasn't on my radar. Thanks for bumping it back into visibility. I'll take a look shortly.

  3. Scott Wells repo owner

    Okay, I'm committing the fixes for this now for inclusion in the next build (perhaps tomorrow but likely Friday due to TDX20):

    Soql_Query_Typeof_Clause.gif

    So sorry this has languished for so long!

  4. Scott Wells repo owner

    Delivered in 2.1.2.7. Please make sure that your OST is properly generated as the code completion features include here depend on the OST's polymorphic field information.

  5. Eric Kintzer

    One last issue with TYPEOF in SOQL - version 2.1.4.5

    The line ELSE Name has Name highlit in Red with inspector error: “unresolvable reference”. This compiles and executes just fine.

    CaseTeamMember[] ctms = [SELECT Id, Parent.CaseNumber,
        TYPEOF Member 
            WHEN User 
                THEN Name,IsActive 
            ELSE Name
        END
    FROM CaseTeamMember];
    

  6. Scott Wells repo owner

    Thanks for letting me know, Eric. Should be simple enough to address--certainly relative to the last pass! I'll take a look for one of the near-term releases.

  7. Scott Wells repo owner

    This is now fixed for inclusion in the next build, both references and code completions for fields in TYPEOF ELSE clauses.

  8. Log in to comment