Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #7798: ora_datetime.patch

File ora_datetime.patch, 1.9 kB (added by mschoen, 2 years ago)
  • activerecord/lib/active_record/connection_adapters/oracle_adapter.rb

    old new  
    162162        # camelCase column names need to be quoted; not that anyone using Oracle 
    163163        # would really do this, but handling this case means we pass the test... 
    164164        def quote_column_name(name) #:nodoc: 
    165           name =~ /[A-Z]/ ? "\"#{name}\"" : name 
     165          name.to_s =~ /[A-Z]/ ? "\"#{name}\"" : name 
    166166        end 
    167167 
    168168        def quote_string(s) #:nodoc: 
     
    507507                when OCI8::LOB 
    508508                  name == 'Writable Large Object' ? row[i]: row[i].read 
    509509                when OraDate 
    510                   if emulate_dates && (row[i].hour == 0 && row[i].minute == 0 && row[i].second == 0) 
    511                     row[i].to_date 
     510                  d = row[i] 
     511                  if emulate_dates && (d.hour == 0 && d.minute == 0 && d.second == 0) 
     512                    d.to_date 
    512513                  else 
    513                     row[i].to_time rescue row[i].to_datetime 
     514                    # see string_to_time; Time overflowing to DateTime, respecting the default timezone 
     515                    time_array = [d.year, d.month, d.day, d.hour, d.minute, d.second] 
     516                    begin 
     517                      Time.send(Base.default_timezone, *time_array) 
     518                    rescue 
     519                      zone_offset = if Base.default_timezone == :local then DateTime.now.offset else 0 end 
     520                      # Append zero calendar reform start to account for dates skipped by calendar reform 
     521                      DateTime.new(*time_array[0..5] << zone_offset << 0) rescue nil 
     522                    end 
    514523                  end 
    515524                else row[i] 
    516525                end unless col == 'raw_rnum_'