fflib-apex-common icon indicating copy to clipboard operation
fflib-apex-common copied to clipboard

QueryFactory addOrdering - Support for Distance

Open tmowbrey opened this issue 8 years ago • 3 comments

At this time, it appears I have no way of creating a query that does the following:

SELECT Id, Name, MailingLatitude, MailingLongitude FROM Contact ORDER BY DISTANCE(MailingAddress, GEOLOCATION(40.7657, -73.9899), 'mi') ASC

Because DISTANCE is not a field, there is no way to call addOrdering to support the above. If this is possible, can someone help me out? If not, I'd like to propose an enhancement.

Thanks!

tmowbrey avatar Oct 30 '16 19:10 tmowbrey

@tmowbrey Create a formula field if you are going to use the same geolcation coordinates

o-lexi avatar Nov 10 '16 23:11 o-lexi

That's easy enough when managing your own org, but I'm using this for a managed package where I don't know the object that I'm querying before hand. I'm asking the end user to provide the compound address or geolocation fields as part of setup. I'd prefer that we determine if we can add an additional method to support distance and geolocation adds to the query factory, if possible.

tmowbrey avatar Nov 10 '16 23:11 tmowbrey

So we want a generic enhancement to support soql functions in select/where/order by clauses. Sounds useful to me. Marked as an enhancement request.

dfruddffdc avatar Nov 14 '16 08:11 dfruddffdc