aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/querying.rb
diff options
context:
space:
mode:
authorSean Griffin <sean@seantheprogrammer.com>2016-02-11 08:54:58 -0700
committerSean Griffin <sean@seantheprogrammer.com>2016-02-11 08:54:58 -0700
commit2a56b2d90d4fed8548e3a1e7a7b206454858c872 (patch)
tree47af48e0929ad7e145f112aa0433584f4e3bfdac /activerecord/lib/active_record/querying.rb
parent3a7a021ed936af50d436f419ac651203cfd072f6 (diff)
downloadrails-2a56b2d90d4fed8548e3a1e7a7b206454858c872.tar.gz
rails-2a56b2d90d4fed8548e3a1e7a7b206454858c872.tar.bz2
rails-2a56b2d90d4fed8548e3a1e7a7b206454858c872.zip
Ensure prepared statement caching still occurs with Adequate Record
In Rails 5, we're much more restrictive about when we do or don't cache a prepared statement. In particular, we never cache when we are sending an IN statement or a SQL string literal However, in the case of Adequate Record, we are *always* sending a raw SQL string, and we *always* want to cache the result. Fixes #23507 /cc @tgxworld
Diffstat (limited to 'activerecord/lib/active_record/querying.rb')
-rw-r--r--activerecord/lib/active_record/querying.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/querying.rb b/activerecord/lib/active_record/querying.rb
index 5259797223..de5b42e987 100644
--- a/activerecord/lib/active_record/querying.rb
+++ b/activerecord/lib/active_record/querying.rb
@@ -35,8 +35,8 @@ module ActiveRecord
#
# Post.find_by_sql ["SELECT title FROM posts WHERE author = ? AND created > ?", author_id, start_date]
# Post.find_by_sql ["SELECT body FROM comments WHERE author = :user_id OR approved_by = :user_id", { :user_id => user_id }]
- def find_by_sql(sql, binds = [])
- result_set = connection.select_all(sanitize_sql(sql), "#{name} Load", binds)
+ def find_by_sql(sql, binds = [], preparable: nil)
+ result_set = connection.select_all(sanitize_sql(sql), "#{name} Load", binds, preparable: preparable)
column_types = result_set.column_types.dup
columns_hash.each_key { |k| column_types.delete k }
message_bus = ActiveSupport::Notifications.instrumenter