aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters')
-rwxr-xr-xactiverecord/lib/active_record/connection_adapters/abstract_adapter.rb24
1 files changed, 10 insertions, 14 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb b/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb
index 11112106f7..fc29f11e15 100755
--- a/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb
@@ -23,7 +23,7 @@ module ActiveRecord
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 @@ module ActiveRecord
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 @@ module ActiveRecord
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 @@ module ActiveRecord
@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)