Incorrect SOQL parsing

Issue #1798 resolved
Phil W created an issue

I have the following code, utilizing a custom object Location__c with a geocoordinate field called Coordinates__c and with a related custom object called Site__c with a name, along with a latitude/longitude pair and a value for a maximum great circle distance:

Location touchLocation = Location.newInstance(latitude, longitude);
List<Location__c> locations = [ // CRUD/FLS False Positive: Location matching must take place regardless of user permissions
        SELECT Id, Name, Site__c, Site__r.Name
                FROM Location__c
                WHERE DISTANCE(Coordinates__c, :touchLocation, 'km') < :maxDistance
        ORDER BY DISTANCE(Coordinates__c, :touchLocation, 'km')
        ASC LIMIT 1
];

The following errors are reported by IC2 but not by Salesforce:

<sobject field name> or GEOLOCATION expected, got ':'

ALL, FOR, GROUP, HAVING, LIMIT, OFFSET, ORDER, UPDATE or WITH expected, got ')'

The editor looks like:

Comments (4)

  1. Phil W reporter

    Hmmm. I just re-generated the OST and reloaded the project. The error remains (I had to click to load the errors for that file again).

  2. Scott Wells repo owner

    The issue here is that I wasn't allowing a bind expression as an argument to the DISTANCE function. The fix will be included in the next build.

  3. Log in to comment