提交 14d50e9d 编写于 作者: J Jeremy Kemper

Oracle: active? check pings the database rather than testing the last command...

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
上级 87c32879
*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]
......
......@@ -116,7 +116,7 @@ def cast_to_time(value)
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 @@ def quote(value, column = nil) #:nodoc:
# 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 @@ def initialize(config, factory = OCIConnectionFactory.new)
# 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.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册