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

adds null_value method for code reuse

parent bdc8c180
No related branches found
No related tags found
No related merge requests found
...@@ -45,8 +45,7 @@ module Geocoder::Store ...@@ -45,8 +45,7 @@ module Geocoder::Store
# If no lat/lon given we don't want any results, but we still # 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: # need distance and bearing columns so you can add, for example:
# .order("distance") # .order("distance")
null_val = using_postgres? ? 'NULL::text' : 'NULL' select(select_clause(nil, null_value, null_value)).where(false_condition)
select(select_clause(nil, null_val, null_val)).where(false_condition)
end end
} }
...@@ -65,8 +64,7 @@ module Geocoder::Store ...@@ -65,8 +64,7 @@ module Geocoder::Store
full_column_name(geocoder_options[:longitude]) full_column_name(geocoder_options[:longitude])
)) ))
else else
null_val = using_postgres? ? 'NULL::text' : 'NULL' select(select_clause(nil, null_value, null_value)).where(false_condition)
select(select_clause(nil, null_val, null_val)).where(false_condition)
end end
} }
end end
...@@ -230,6 +228,13 @@ module Geocoder::Store ...@@ -230,6 +228,13 @@ module Geocoder::Store
connection.adapter_name.match(/postgres/i) connection.adapter_name.match(/postgres/i)
end 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. # 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.
Finish editing this message first!
Please register or to comment