aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorRafael França <rafaelmfranca@gmail.com>2017-06-29 12:02:55 -0400
committerGitHub <noreply@github.com>2017-06-29 12:02:55 -0400
commit9c2ad53beff12cdc7b30dcfaa9d44eda38f7c68c (patch)
treee67daafb5fefb308ea6663867e6632dee7ec5df1 /activerecord/lib
parent47c74e3dfe4e2532f9a4bc631b73b03fd7623fb8 (diff)
parentabbc8351cd19f676476242bd6a0836b83dc3f0f0 (diff)
downloadrails-9c2ad53beff12cdc7b30dcfaa9d44eda38f7c68c.tar.gz
rails-9c2ad53beff12cdc7b30dcfaa9d44eda38f7c68c.tar.bz2
rails-9c2ad53beff12cdc7b30dcfaa9d44eda38f7c68c.zip
Merge pull request #29623 from kamipo/should_use_same_connection_in_query_cache
Should use the same connection in using query cache
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb1
-rw-r--r--activerecord/lib/active_record/log_subscriber.rb7
2 files changed, 4 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb b/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb
index 33695c0537..c352ddfc11 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb
@@ -108,6 +108,7 @@ module ActiveRecord
"sql.active_record",
sql: sql,
binds: binds,
+ type_casted_binds: -> { type_casted_binds(binds) },
name: name,
connection_id: object_id,
cached: true,
diff --git a/activerecord/lib/active_record/log_subscriber.rb b/activerecord/lib/active_record/log_subscriber.rb
index 2297c77835..e39ca5f6dc 100644
--- a/activerecord/lib/active_record/log_subscriber.rb
+++ b/activerecord/lib/active_record/log_subscriber.rb
@@ -29,7 +29,7 @@ module ActiveRecord
binds = nil
unless (payload[:binds] || []).empty?
- casted_params = type_casted_binds(payload[:binds], payload[:type_casted_binds])
+ casted_params = type_casted_binds(payload[:type_casted_binds])
binds = " " + payload[:binds].zip(casted_params).map { |attr, value|
render_bind(attr, value)
}.inspect
@@ -42,9 +42,8 @@ module ActiveRecord
end
private
-
- def type_casted_binds(binds, casted_binds)
- casted_binds || ActiveRecord::Base.connection.type_casted_binds(binds)
+ def type_casted_binds(casted_binds)
+ casted_binds.respond_to?(:call) ? casted_binds.call : casted_binds
end
def render_bind(attr, value)