I'm using the new Geolocation field data type and SOQL DISTANCE function in a Visualforce page. I'm using the SOQL with DISTANCE to retrieve records into a standardSetController. It works great - records are retrieved and displayed successfully.
However, when I run unit tests, I get inconsistent failures. When I run in the IDE, the unit test runs fine. Then I go immediately to the UI and run the same unit test and I get a failure -- No such column Location__c on entity Person__c
-- on the SOQL statement with DISTANCE. (Location__c is the Geolocation field, of course.)
Then I immediately go to the IDE to run the unit test, and now it fails with the same error.
So I comment out sections in the unit test, deploy the VF code to production, and the page works great. But of course I have very low test coverage on the controller.
Why does the VF page work fine in the UI, but the unit test fail? Does it have to do with the way test data is set up in the unit test? But even if the Location_Latitude_s and Location_Longitude_s fields are null, the SOQL query shouldn't throw a "no such column" error.
I'm using API 26 in the IDE. I'm on sandbox cs7.
My basic SOQL statement is SELECT DISTANCE(Location__c, GEOLOCATION(xxx, yyy), 'mi') < 10 ORDER BY DISTANCE(Location__c, GEOLOCATION(xxx, yyy), 'mi')
. I've read that ORDER BY is not supported, but it does work in the VF page.