Class: ActiveRecord::ConnectionAdapters::Column

Inherits:
Object
  • Object
show all
Defined in:
lib/rubyrep/connection_extenders/connection_extenders.rb

Direct Known Subclasses

PostgreSQLColumn

Class Method Summary collapse

Class Method Details

.fast_string_to_time(string) ⇒ Object

Bug in ActiveRecord parsing of PostgreSQL timestamps with microseconds: Certain values are incorrectly rounded, thus ending up with timestamps that are off by one microsecond. This monkey patch fixes the problem.



11
12
13
14
15
16
# File 'lib/rubyrep/connection_extenders/connection_extenders.rb', line 11

def self.fast_string_to_time(string)
  if string =~ Format::ISO_DATETIME
    microsec = ($7.to_f * 1_000_000).round # used to be #to_i instead
    new_time $1.to_i, $2.to_i, $3.to_i, $4.to_i, $5.to_i, $6.to_i, microsec
  end
end