aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorMatthew Dunbar <matthew.dunbar@lifeway.com>2019-02-14 23:07:01 -0500
committerMatthew Dunbar <matthew.dunbar@lifeway.com>2019-02-14 23:25:44 -0500
commit795c0f8205a23af4dc928b46d15279b57d8ef3c3 (patch)
treec8a88ef6ac5fd353823fb6e1e2262959792e807e /activerecord/lib
parentc43c83984792ac546e7610c898cf9099cc1a2ee6 (diff)
downloadrails-795c0f8205a23af4dc928b46d15279b57d8ef3c3.tar.gz
rails-795c0f8205a23af4dc928b46d15279b57d8ef3c3.tar.bz2
rails-795c0f8205a23af4dc928b46d15279b57d8ef3c3.zip
Properly handle cached queries with too many bind parameters
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb6
1 files changed, 6 insertions, 0 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 4e55fcae2f..d950099bab 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb
@@ -96,6 +96,12 @@ module ActiveRecord
if @query_cache_enabled && !locked?(arel)
arel = arel_from_relation(arel)
sql, binds = to_sql_and_binds(arel, binds)
+
+ if binds.length > bind_params_length
+ sql, binds = unprepared_statement { to_sql_and_binds(arel) }
+ preparable = false
+ end
+
cache_sql(sql, name, binds) { super(sql, name, binds, preparable: preparable) }
else
super