We were on version 2.3.1 where ActiveRecord Query
Bike.within('0.2', origin: Geokit::LatLng.new('-33.4125', '-70.5632')).to_sql
will yield
SELECT `bikes`.* FROM `bikes` WHERE (bikes.latitude IS NOT NULL AND bikes.longitude IS NOT NULL)
AND (bikes.latitude>-33.415391397057064 AND bikes.latitude<-33.409608602942924 AND bikes.longitude>-70.56666388036811 AND bikes.longitude<-70.55973611963188)
AND ((
(ACOS(least(1,COS(-0.5831581363226054)*COS(-1.2315601707432626)*COS(RADIANS(bikes.latitude))*COS(RADIANS(bikes.longitude))+
COS(-0.5831581363226054)*SIN(-1.2315601707432626)*COS(RADIANS(bikes.latitude))*SIN(RADIANS(bikes.longitude))+
SIN(-0.5831581363226054)*SIN(RADIANS(bikes.latitude))))*3963.1899999999996)
<= 0.2))
On 2.5.0, same yields -
SELECT `bikes`.* FROM `bikes` WHERE (bikes.latitude IS NOT NULL AND bikes.longitude IS NOT NULL) AND
(ACOS(least(1,COS(-0.5831581363226054)*COS(-1.2315601707432626)*COS(RADIANS(bikes.latitude))*COS(RADIANS(bikes.longitude))+
COS(-0.5831581363226054)*SIN(-1.2315601707432626)*COS(RADIANS(bikes.latitude))*SIN(RADIANS(bikes.longitude))+
SIN(-0.5831581363226054)*SIN(RADIANS(bikes.latitude))))*3963.1899999999996)
<= '0.2'
The extra where clause - (bikes.latitude>-33.415391397057064 AND bikes.latitude<-33.409608602942924 AND bikes.longitude>-70.56666388036811 AND bikes.longitude<-70.55973611963188) is missing which makes the query ineffecient.
In 2.5.0; passing radius as a Float or Integer does the right thing.
I understand the original call of passing radius as a String was itself incorrect, but I feel it's still a regression that should be surfaced up.
We were on version
2.3.1
where ActiveRecord QueryBike.within('0.2', origin: Geokit::LatLng.new('-33.4125', '-70.5632')).to_sql
will yield
On 2.5.0, same yields -
The extra where clause -
(bikes.latitude>-33.415391397057064 AND bikes.latitude<-33.409608602942924 AND bikes.longitude>-70.56666388036811 AND bikes.longitude<-70.55973611963188)
is missing which makes the query ineffecient.In 2.5.0; passing radius as a
Float
orInteger
does the right thing.I understand the original call of passing
radius
as a String was itself incorrect, but I feel it's still a regression that should be surfaced up.