Permalink
Browse files

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

…hrough.
  • Loading branch information...
1 parent 4ff2c8d commit 0590e33c4a9bfdf2e12f89f357696f1b81785234 Simon Peck committed Sep 20, 2011
Showing with 11 additions and 4 deletions.
  1. +10 −3 lib/geocoder/stores/active_record.rb
  2. +1 −1 lib/geocoder/version.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
@@ -1,3 +1,3 @@
module Geocoder
- VERSION = "1.0.4"
+ VERSION = "1.0.5"
end

0 comments on commit 0590e33

Please sign in to comment.