From 60df0428f56c0887c52259fb7925ebcda8eec43b Mon Sep 17 00:00:00 2001 From: Weston Triemstra <weston@netsign.com> Date: Sun, 20 Jun 2010 02:51:41 -0700 Subject: [PATCH] support :select parameter for options hash given to ActiveRecord.find --- lib/geocoder.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/geocoder.rb b/lib/geocoder.rb index 95548ab0..9e4fe686 100644 --- a/lib/geocoder.rb +++ b/lib/geocoder.rb @@ -52,6 +52,7 @@ module Geocoder # +order+ :: column(s) for ORDER BY SQL clause # +limit+ :: number of records to return (for LIMIT SQL clause) # +offset+ :: number of records to skip (for OFFSET SQL clause) + # +select+ :: string with the SELECT SQL fragment (e.g. “id, nameâ€) # def near_scope_options(latitude, longitude, radius = 20, options = {}) if ActiveRecord::Base.connection.adapter_name == "SQLite" @@ -82,7 +83,7 @@ module Geocoder "POWER(SIN((#{longitude} - #{lon_attr}) * " + "PI() / 180 / 2), 2) ))" default_near_scope_options(latitude, longitude, radius, options).merge( - :select => "*, #{distance} AS distance", + :select => "#{options[:select] || '*'}, #{distance} AS distance", :conditions => \ ["#{lat_attr} BETWEEN ? AND ? AND #{lon_attr} BETWEEN ? AND ?"] + coordinate_bounds(latitude, longitude, radius), -- GitLab