diff --git a/lib/geocoder/stores/active_record.rb b/lib/geocoder/stores/active_record.rb index dbadd213573e1fa8111b49a34e17db6c72ad0900..1c0ab935366a87aa9dc021dacabc8dffbb01f941 100644 --- a/lib/geocoder/stores/active_record.rb +++ b/lib/geocoder/stores/active_record.rb @@ -45,8 +45,7 @@ module Geocoder::Store # If no lat/lon given we don't want any results, but we still # need distance and bearing columns so you can add, for example: # .order("distance") - null_val = using_postgres? ? 'NULL::text' : 'NULL' - select(select_clause(nil, null_val, null_val)).where(false_condition) + select(select_clause(nil, null_value, null_value)).where(false_condition) end } @@ -65,8 +64,7 @@ module Geocoder::Store full_column_name(geocoder_options[:longitude]) )) else - null_val = using_postgres? ? 'NULL::text' : 'NULL' - select(select_clause(nil, null_val, null_val)).where(false_condition) + select(select_clause(nil, null_value, null_value)).where(false_condition) end } end @@ -230,6 +228,13 @@ module Geocoder::Store connection.adapter_name.match(/postgres/i) end + ## + # Use OID type when running in PosgreSQL + # + def null_value + using_postgres? ? 'NULL::text' : 'NULL' + end + ## # Value which can be passed to where() to produce no results. #