From 5e08c5b63bd2fc566f1d16f4eee35b493cbf88b8 Mon Sep 17 00:00:00 2001
From: gugl <guenter@thiinkstrata.com>
Date: Wed, 4 Apr 2012 13:19:51 +0200
Subject: [PATCH] added :ignore option for :select when using ActiveRecord

---
 lib/geocoder/stores/active_record.rb | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/lib/geocoder/stores/active_record.rb b/lib/geocoder/stores/active_record.rb
index 6701f244..7b441f16 100644
--- a/lib/geocoder/stores/active_record.rb
+++ b/lib/geocoder/stores/active_record.rb
@@ -142,7 +142,7 @@ module Geocoder::Store
         distance = full_distance_from_sql(latitude, longitude, options)
         conditions = ["#{distance} <= ?", radius]
         default_near_scope_options(latitude, longitude, radius, options).merge(
-          :select => "#{options[:select] || full_column_name("*")}, " +
+          :select => select_addon(options) +
             "#{distance} AS distance" +
             (bearing ? ", #{bearing} AS bearing" : ""),
           :conditions => add_exclude_condition(conditions, options[:exclude])
@@ -211,13 +211,20 @@ module Geocoder::Store
           [b[0], b[2], b[1], b[3]
         ]
         default_near_scope_options(latitude, longitude, radius, options).merge(
-          :select => "#{options[:select] || full_column_name("*")}, " +
+          :select => select_addon(options) +
             "#{distance} AS distance" +
             (bearing ? ", #{bearing} AS bearing" : ""),
           :conditions => add_exclude_condition(conditions, options[:exclude])
         )
       end
 
+      ##
+      # Select string to add
+      #
+      def select_addon(options)
+        options[:select] == :ignore ? "" : "#{options[:select] || full_column_name("*")}, "
+      end
+
       ##
       # Options used for any near-like scope.
       #
-- 
GitLab