diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2007-03-12 05:44:01 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2007-03-12 05:44:01 +0000 |
commit | bedb879913903e7b2548db7d67a57111b30fa267 (patch) | |
tree | 31f8f39950dca6e9b0258d23e50bac09b2c09cd3 /activerecord | |
parent | 8e0114385406b047c4b8b06c533237bf0bc83a97 (diff) | |
download | rails-bedb879913903e7b2548db7d67a57111b30fa267.tar.gz rails-bedb879913903e7b2548db7d67a57111b30fa267.tar.bz2 rails-bedb879913903e7b2548db7d67a57111b30fa267.zip |
Oracle: fix quoted primary keys and datetime overflow. Closes #7798.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6388 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/CHANGELOG | 2 | ||||
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/oracle_adapter.rb | 17 |
2 files changed, 15 insertions, 4 deletions
diff --git a/activerecord/CHANGELOG b/activerecord/CHANGELOG index d044c7a845..cbe9b8c4f0 100644 --- a/activerecord/CHANGELOG +++ b/activerecord/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Oracle: fix quoted primary keys and datetime overflow. #7798 [Michael Schoen] + * Consistently quote primary key column names. #7763 [toolmantim] * Fixtures: fix YAML ordered map support. #2665 [Manuel Holtgrewe, nfbuckley] diff --git a/activerecord/lib/active_record/connection_adapters/oracle_adapter.rb b/activerecord/lib/active_record/connection_adapters/oracle_adapter.rb index 0dc0513356..8b555b1466 100644 --- a/activerecord/lib/active_record/connection_adapters/oracle_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/oracle_adapter.rb @@ -162,7 +162,7 @@ begin # camelCase column names need to be quoted; not that anyone using Oracle # would really do this, but handling this case means we pass the test... def quote_column_name(name) #:nodoc: - name =~ /[A-Z]/ ? "\"#{name}\"" : name + name.to_s =~ /[A-Z]/ ? "\"#{name}\"" : name end def quote_string(s) #:nodoc: @@ -507,10 +507,19 @@ begin when OCI8::LOB name == 'Writable Large Object' ? row[i]: row[i].read when OraDate - if emulate_dates && (row[i].hour == 0 && row[i].minute == 0 && row[i].second == 0) - row[i].to_date + d = row[i] + if emulate_dates && (d.hour == 0 && d.minute == 0 && d.second == 0) + d.to_date else - row[i].to_time rescue row[i].to_datetime + # see string_to_time; Time overflowing to DateTime, respecting the default timezone + time_array = [d.year, d.month, d.day, d.hour, d.minute, d.second] + begin + Time.send(Base.default_timezone, *time_array) + rescue + zone_offset = if Base.default_timezone == :local then DateTime.now.offset else 0 end + # Append zero calendar reform start to account for dates skipped by calendar reform + DateTime.new(*time_array[0..5] << zone_offset << 0) rescue nil + end end else row[i] end unless col == 'raw_rnum_' |