Query.apex icon indicating copy to clipboard operation
Query.apex copied to clipboard

Support DISTANCE function

Open HenryRLee opened this issue 6 years ago • 0 comments

https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_geolocate.htm

I haven't come up with a design yet.

Anyway, the feature is still available by manually feeding the whole DISTANCE expression to the first parameter of the methods addConditionXX or orderBy.

For example:

new Query('Account')
.addConditionGt('DISTANCE(Location__c, GEOLOCATION(37.775,-122.418), \'mi\')', 10);
new Query('Account')
.orderBy('DISTANCE(Location__c, GEOLOCATION(37.775,-122.418), \'mi\')', 'DESC');

It's just this way of coding does not fit the style of Query.apex.

HenryRLee avatar Nov 25 '19 02:11 HenryRLee