diff --git a/lib/geocoder/stores/active_record.rb b/lib/geocoder/stores/active_record.rb index 91fabe05b126cfcb282a8e5f29140b543a38932a..dbadd213573e1fa8111b49a34e17db6c72ad0900 100644 --- a/lib/geocoder/stores/active_record.rb +++ b/lib/geocoder/stores/active_record.rb @@ -45,7 +45,8 @@ 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") - select(select_clause(nil, "NULL", "NULL")).where(false_condition) + null_val = using_postgres? ? 'NULL::text' : 'NULL' + select(select_clause(nil, null_val, null_val)).where(false_condition) end } @@ -64,7 +65,8 @@ module Geocoder::Store full_column_name(geocoder_options[:longitude]) )) else - select(select_clause(nil, "NULL", "NULL")).where(false_condition) + null_val = using_postgres? ? 'NULL::text' : 'NULL' + select(select_clause(nil, null_val, null_val)).where(false_condition) end } end @@ -224,6 +226,10 @@ module Geocoder::Store connection.adapter_name.match(/sqlite/i) end + def using_postgres? + connection.adapter_name.match(/postgres/i) + end + ## # Value which can be passed to where() to produce no results. #