File tree Expand file tree Collapse file tree 1 file changed +8
-6
lines changed
Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -172,9 +172,15 @@ def type_cast(value, type = false) # AR >= 4.0 version
172172 from = self . class . string_to_time ( extracted [ :from ] )
173173 to = self . class . string_to_time ( extracted [ :to ] )
174174 when 'int4' , 'int8' # :integer
175- from = to_integer ( extracted [ :from ] ) rescue value ? 1 : 0
175+ from = extracted [ :from ]
176+ unless ( from . respond_to? ( :infinite? ) && from . infinite? )
177+ from = from . respond_to? ( :to_i ) ? from . to_i : ( value ? 1 : 0 )
178+ end
176179 from += 1 if extracted [ :exclude_start ]
177- to = to_integer ( extracted [ :to ] ) rescue value ? 1 : 0
180+ to = extracted [ :to ]
181+ unless ( to . respond_to? ( :infinite? ) && to . infinite? )
182+ to = to . respond_to? ( :to_i ) ? to . to_i : ( value ? 1 : 0 )
183+ end
178184 else
179185 return value
180186 end
@@ -321,10 +327,6 @@ def infinity(options = {})
321327 ::Float ::INFINITY * ( options [ :negative ] ? -1 : 1 )
322328 end if AR4_COMPAT
323329
324- def to_integer ( value )
325- ( value . respond_to? ( :infinite? ) && value . infinite? ) ? value : value . to_i
326- end if AR4_COMPAT
327-
328330 # @note Based on *active_record/connection_adapters/postgresql/cast.rb* (4.0).
329331 module Cast
330332
You can’t perform that action at this time.
0 commit comments