Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed a bug where additional SQL conditions were not getting passed t…

…hrough.
  • Loading branch information...
commit 0590e33c4a9bfdf2e12f89f357696f1b81785234 1 parent 4ff2c8d
@latensified authored
Showing with 11 additions and 4 deletions.
  1. +10 −3 lib/geocoder/stores/active_record.rb
  2. +1 −1  lib/geocoder/version.rb
View
13 lib/geocoder/stores/active_record.rb
@@ -170,9 +170,16 @@ def default_near_scope_options(latitude, longitude, radius, options)
lat_attr = geocoder_options[:latitude]
lon_attr = geocoder_options[:longitude]
b = Geocoder::Calculations.bounding_box([latitude, longitude], radius, options)
- conditions = \
- ["#{lat_attr} BETWEEN ? AND ? AND #{lon_attr} BETWEEN ? AND ?"] +
- [b[0], b[2], b[1], b[3]]
+ query = ["#{lat_attr} BETWEEN ? AND ? AND #{lon_attr} BETWEEN ? AND ?"]
+ variables = [b[0], b[2], b[1], b[3]]
+ options[:conditions].each_with_index { |condition, index|
+ if (index.modulo 2) == 0
+ query[0] += " #{condition}"
+ else
+ variables << condition
+ end
+ }
+ conditions = query + variables
if obj = options[:exclude]
conditions[0] << " AND #{table_name}.id != ?"
conditions << obj.id
View
2  lib/geocoder/version.rb
@@ -1,3 +1,3 @@
module Geocoder
- VERSION = "1.0.4"
+ VERSION = "1.0.5"
end
Please sign in to comment.
Something went wrong with that request. Please try again.