diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2005-11-24 19:50:10 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2005-11-24 19:50:10 +0000 |
commit | 14d50e9da3bb67a881afc2aed2662b5c10005eec (patch) | |
tree | 0daa541d6067b9bbaadd6d9ff3402e90e9074171 /activerecord | |
parent | 87c328791282510c90638fc9ab2418dd08b01383 (diff) | |
download | rails-14d50e9da3bb67a881afc2aed2662b5c10005eec.tar.gz rails-14d50e9da3bb67a881afc2aed2662b5c10005eec.tar.bz2 rails-14d50e9da3bb67a881afc2aed2662b5c10005eec.zip |
Oracle: active? check pings the database rather than testing the last command status. References #428.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3189 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/CHANGELOG | 2 | ||||
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/oci_adapter.rb | 32 |
2 files changed, 17 insertions, 17 deletions
diff --git a/activerecord/CHANGELOG b/activerecord/CHANGELOG index bdbb9e8b07..3d635fbf62 100644 --- a/activerecord/CHANGELOG +++ b/activerecord/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Oracle: active? check pings the database rather than testing the last command status. #428 [Michael Schoen] + * SQLServer: resolve column aliasing/quoting collision when using limit or offset in an eager find. #2974 [kajism@yahoo.com] * Reloading a model doesn't lose track of its connection. #2996 [junk@miriamtech.com, Jeremy Kemper] diff --git a/activerecord/lib/active_record/connection_adapters/oci_adapter.rb b/activerecord/lib/active_record/connection_adapters/oci_adapter.rb index d615ba33a1..1580dcac85 100644 --- a/activerecord/lib/active_record/connection_adapters/oci_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/oci_adapter.rb @@ -116,7 +116,7 @@ begin return value if value.is_a? Time time_array = ParseDate.parsedate value time_array[0] ||= 2000; time_array[1] ||= 1; time_array[2] ||= 1; - Time.send Base.default_timezone, *time_array + Time.send(Base.default_timezone, *time_array) rescue nil end def guess_date_or_time(value) @@ -215,20 +215,20 @@ begin # Returns true if the connection is active. def active? - # Just checks the active flag, which is set false if the last exec - # got an error indicating a bad connection. An alternative would be - # to call #ping, which is more expensive (and should always get - # the same result). - @connection.active? + # Pings the connection to check if it's still good. Note that an + # #active? method is also available, but that simply returns the + # last known state, which isn't good enough if the connection has + # gone stale since the last use. + @connection.ping + rescue OCIError + false end # Reconnects to the database. def reconnect! - begin - @connection.reset! - rescue OCIError => e - @logger.warn "#{adapter_name} automatic reconnection failed: #{e.message}" - end + @connection.reset! + rescue OCIError => e + @logger.warn "#{adapter_name} automatic reconnection failed: #{e.message}" end @@ -551,13 +551,11 @@ begin # checks the connection, while #active? simply returns the last # known state. def ping + @connection.commit @active = true - begin - @connection.commit - rescue - @active = false - end - active? + rescue + @active = false + raise end # Resets connection, by logging off and creating a new connection. |