-
Notifications
You must be signed in to change notification settings - Fork 244
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
Add NOT NULL checks for latitude and longitude #86
Conversation
…lues are being returned for distance calculations involving such objects.
end | ||
|
||
def not_null | ||
where("#{qualified_lat_column_name} IS NOT NULL AND #{qualified_lng_column_name} IS NOT NULL") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line is too long. [102/80]
…lues are being returned for distance calculations involving such objects.
@@ -137,7 +137,11 @@ def by_distance(options = {}) | |||
bounds = extract_bounds_from_options(options) | |||
distance_column_name = distance_sql(origin, units, formula) | |||
#geo_scope(options).order("#{distance_column_name} asc") | |||
order("#{distance_column_name} #{options[:reverse] ? 'DESC' : 'ASC'}") | |||
not_null_latlng.order("#{distance_column_name} #{options[:reverse] ? 'DESC' : 'ASC'}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line is too long. [94/80]
@@ -140,7 +140,11 @@ def by_distance(options = {}) | |||
bounds = extract_bounds_from_options(options) | |||
distance_column_name = distance_sql(origin, units, formula) | |||
#geo_scope(options).order("#{distance_column_name} asc") | |||
order("#{distance_column_name} #{options[:reverse] ? 'DESC' : 'ASC'}") | |||
with_latlng.order("#{distance_column_name} #{options[:reverse] ? 'DESC' : 'ASC'}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line is too long. [90/80]
Please look at the Travis CI failures, they are not caused by my code. Thanks! |
Add NOT NULL checks for latitude and longitude
You're right. I tried to have a quick look at the CI failures but it seems it's getting rather complex and I'll need to spend some time ensuring it works correctly in all ruby/rails versions before I release the next version of the gem. |
Good :-), because I have another PR pending (add bounding box around |
... otherwise nonsense values are being returned for distance calculations involving such objects.
Added a test fixture without latitude and longitude to make existing tests fail if they do not test for NULL lat/lng values.