Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor Regression between 2.3.1 and 2.5.0 #161

Open
rahul342 opened this issue Nov 10, 2023 · 0 comments
Open

Minor Regression between 2.3.1 and 2.5.0 #161

rahul342 opened this issue Nov 10, 2023 · 0 comments

Comments

@rahul342
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant