提交 be408bd4 编写于 作者: J Jeremy Kemper

Fix @logger.debug? conditional considering @logger may be nil.

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6375 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
上级 9cc32a9e
......@@ -23,7 +23,7 @@ module ConnectionAdapters # :nodoc:
class AbstractAdapter
include Quoting, DatabaseStatements, SchemaStatements
@@row_even = true
def initialize(connection, logger = nil) #:nodoc:
@connection, @logger = connection, logger
@runtime = 0
......@@ -41,7 +41,7 @@ def adapter_name
def supports_migrations?
false
end
# Does this adapter support using DISTINCT within COUNT? This is +true+
# for all adapters except sqlite.
def supports_count_distinct?
......@@ -86,7 +86,7 @@ def requires_reloading?
end
# Lazily verify this connection, calling +active?+ only if it hasn't
# been called for +timeout+ seconds.
# been called for +timeout+ seconds.
def verify!(timeout)
now = Time.now.to_i
if (now - @last_verification) > timeout
......@@ -94,24 +94,20 @@ def verify!(timeout)
@last_verification = now
end
end
# Provides access to the underlying database connection. Useful for
# when you need to call a proprietary method such as postgresql's lo_*
# methods
def raw_connection
@connection
end
def log_info(sql, name, runtime)
return unless @logger or !@logger.debug?
@logger.debug(
format_log_entry(
"#{name.nil? ? "SQL" : name} (#{sprintf("%f", runtime)})",
sql.gsub(/ +/, " ")
)
)
end
if @logger && @logger.debug?
name = "#{name.nil? ? "SQL" : name} (#{sprintf("%f", runtime)})"
@logger.debug format_log_entry(name, sql.squeeze(' '))
end
end
protected
def log(sql, name)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册