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

Changeset 6388

Show
Ignore:
Timestamp:
03/12/07 05:44:01 (1 year ago)
Author:
bitsweat
Message:

Oracle: fix quoted primary keys and datetime overflow. Closes #7798.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/activerecord/CHANGELOG

    r6364 r6388  
    11*SVN* 
     2 
     3* Oracle: fix quoted primary keys and datetime overflow.  #7798 [Michael Schoen] 
    24 
    35* Consistently quote primary key column names.  #7763 [toolmantim] 
  • trunk/activerecord/lib/active_record/connection_adapters/oracle_adapter.rb

    r6348 r6388  
    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 
     
    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]