SELECT
(ACOS(least(1,COS(0.5410520681182421)*COS(0.5061454830783556)*COS(RADIANS(31.15))*COS(RADIANS(29.8))+COS(0.5410520681182421)*SIN(0.5061454830783556)*COS(RADIANS(31.15))*SIN(RADIANS(29.8))+SIN(0.5410520681182421)*SIN(RADIANS(31.15))))*6376.77271) AS distance;
This query get same result 78.06486321137547 under MySQL and PostgreSQL.
But when I use ActiveRecord to do this query:
ActiveRecord::Base.connection.execute("SELECT (ACOS(least(1,COS(0.5410520681182421)*COS(0.5061454830783556)*COS(RADIANS(31.15))*COS(RADIANS(29.8))+COS(0.5410520681182421)*SIN(0.5061454830783556)*COS(RADIANS(31.15))*SIN(RADIANS(29.8))+SIN(0.5410520681182421)*SIN(RADIANS(31.15))))*6376.77271) AS distance")
This query get same result
78.06486321137547
under MySQL and PostgreSQL.But when I use ActiveRecord to do this query:
I get different resutls:
78.06486321137547
under MysQL with ActiveRecord78.0648632113755
under Postgres with ActiveRecord