Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix issue #199.

Return zero results more reliably. Formerly an exception was raised when
the table didn't have an 'id' column.
  • Loading branch information...
commit eba79f257fc880e4ed01e4f209b302d051573bf3 1 parent 864fc7b
Alex Reisner authored
Showing with 8 additions and 1 deletion.
  1. +8 −1 lib/geocoder/stores/active_record.rb
9 lib/geocoder/stores/active_record.rb
View
@@ -36,7 +36,7 @@ def self.included(base)
if latitude and longitude
near_scope_options(latitude, longitude, *args)
else
- where(:id => false) # no results if no lat/lon given
+ where(false_condition) # no results if no lat/lon given
end
}
@@ -244,6 +244,13 @@ def add_exclude_condition(conditions, exclude)
def using_sqlite?
connection.adapter_name.match /sqlite/i
end
+
+ ##
+ # Value which can be passed to where() to produce no results.
+ #
+ def false_condition
+ using_sqlite? ? 0 : "false"
+ end
end
##
Please sign in to comment.
Something went wrong with that request. Please try again.