diff --git a/lib/geocoder/stores/active_record.rb b/lib/geocoder/stores/active_record.rb index 91fabe05b126cfcb282a8e5f29140b543a38932a..1c0ab935366a87aa9dc021dacabc8dffbb01f941 100644 --- a/lib/geocoder/stores/active_record.rb +++ b/lib/geocoder/stores/active_record.rb @@ -45,7 +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") - select(select_clause(nil, "NULL", "NULL")).where(false_condition) + select(select_clause(nil, null_value, null_value)).where(false_condition) end } @@ -64,7 +64,7 @@ module Geocoder::Store full_column_name(geocoder_options[:longitude]) )) else - select(select_clause(nil, "NULL", "NULL")).where(false_condition) + select(select_clause(nil, null_value, null_value)).where(false_condition) end } end @@ -224,6 +224,17 @@ module Geocoder::Store connection.adapter_name.match(/sqlite/i) end + def using_postgres? + 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. #