From df68c45ed0390d812689a439772821dd70791869 Mon Sep 17 00:00:00 2001 From: Jev Zelenkov <jev@jz.ee> Date: Sat, 18 Oct 2014 13:09:33 +0200 Subject: [PATCH] adds null_value method for code reuse --- lib/geocoder/stores/active_record.rb | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/geocoder/stores/active_record.rb b/lib/geocoder/stores/active_record.rb index dbadd213..1c0ab935 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. # -- GitLab