From a60dd471537855c88a5041e72261aca1b9b7a4e1 Mon Sep 17 00:00:00 2001 From: Alex Reisner <alex@alexreisner.com> Date: Thu, 31 Mar 2011 22:56:00 -0400 Subject: [PATCH] Deprecate :limit and :offset options to 'near'. --- lib/geocoder/orms/active_record.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/geocoder/orms/active_record.rb b/lib/geocoder/orms/active_record.rb index b4079dae..11af243d 100644 --- a/lib/geocoder/orms/active_record.rb +++ b/lib/geocoder/orms/active_record.rb @@ -63,9 +63,7 @@ module Geocoder::Orm # between the given point and each found nearby point; # set to false for no bearing calculation # * +:select+ - string with the SELECT SQL fragment (e.g. “id, nameâ€) - # * +: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) + # * +:order+ - column(s) for ORDER BY SQL clause; default is distance # * +:exclude+ - an object to exclude (used by the +nearbys+ method) # def near_scope_options(latitude, longitude, radius = 20, options = {}) @@ -183,6 +181,9 @@ module Geocoder::Orm conditions[0] << " AND #{table_name}.id != ?" conditions << obj.id end + if options[:limit] || options[:offset] + warn "DEPRECATION WARNING: The :limit and :offset options to Geocoder's 'near' method are deprecated and will be removed in Geocoder v1.0. Please specify these options using ARel relations instead, for example: Place.near(...).limit(10).offset(20)." + end { :group => columns.map{ |c| "#{table_name}.#{c.name}" }.join(','), :order => options[:order], -- GitLab