diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2011-02-09 15:15:37 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2011-02-09 15:15:37 -0800 |
commit | c560c8b2ba2af2ff1942e40b8eff8287354bf7d8 (patch) | |
tree | 5ce75d028bc92fdd405a09f48d8e9dca1ccdb9cd /activerecord | |
parent | 37efb517cb87c0894d8ecaa2066c5be6283f5450 (diff) | |
download | rails-c560c8b2ba2af2ff1942e40b8eff8287354bf7d8.tar.gz rails-c560c8b2ba2af2ff1942e40b8eff8287354bf7d8.tar.bz2 rails-c560c8b2ba2af2ff1942e40b8eff8287354bf7d8.zip |
log method takes an option list of bind values
Diffstat (limited to 'activerecord')
4 files changed, 10 insertions, 8 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb b/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb index 3a3a73fc42..0f44baa2fe 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb @@ -209,11 +209,13 @@ module ActiveRecord protected - def log(sql, name = "SQL") - @instrumenter.instrument("sql.active_record", - :sql => sql, :name => name, :connection_id => object_id) do - yield - end + def log(sql, name = "SQL", binds = []) + @instrumenter.instrument( + "sql.active_record", + :sql => sql, + :name => name, + :connection_id => object_id, + :binds => binds) { yield } rescue Exception => e message = "#{e.class.name}: #{e.message}: #{sql}" @logger.debug message if @logger diff --git a/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb b/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb index cdf1ebfee4..368c5b2023 100644 --- a/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb @@ -331,7 +331,7 @@ module ActiveRecord end def exec_query(sql, name = 'SQL', binds = []) - log(sql, name) do + log(sql, name, binds) do result = nil cache = {} diff --git a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb index 46c0f3fafe..20be4a22ea 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb @@ -532,7 +532,7 @@ module ActiveRecord def exec_query(sql, name = 'SQL', binds = []) return exec_no_cache(sql, name) if binds.empty? - log(sql, name) do + log(sql, name, binds) do unless @statements.key? sql nextkey = "a#{@statements.length + 1}" @connection.prepare nextkey, sql diff --git a/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb b/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb index f650a1bc74..9ee6b88ab6 100644 --- a/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb @@ -148,7 +148,7 @@ module ActiveRecord # DATABASE STATEMENTS ====================================== def exec_query(sql, name = nil, binds = []) - log(sql, name) do + log(sql, name, binds) do # Don't cache statements without bind values if binds.empty? |