Skip to content
Snippets Groups Projects
Commit bdc8c180 authored by Jev Zelenkov's avatar Jev Zelenkov
Browse files

Fixes OID warnings when using PostgreSQL

Postgres correctly identifies OIDs when BEARING and DISTANCE contain
numerical values. It fails to identify OID for a NULL type.

This patch explicitly sets an OID type for NULLs when running in
PostgreSQL environment.
parent f04fed05
No related branches found
No related tags found
No related merge requests found
......@@ -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.
#
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment