aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/bind_parameter_test.rb
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2019-02-16 14:07:50 +0900
committerRyuta Kamizono <kamipo@gmail.com>2019-02-16 14:16:44 +0900
commitb35339184671ef5ee6ec6f4b09f47ea81118079a (patch)
treea22101357779ea41a6b8cff6b38567e1c87e4c44 /activerecord/test/cases/bind_parameter_test.rb
parentf851e4a5db06d3d18935709ace49d7900dbb6860 (diff)
parent795c0f8205a23af4dc928b46d15279b57d8ef3c3 (diff)
downloadrails-b35339184671ef5ee6ec6f4b09f47ea81118079a.tar.gz
rails-b35339184671ef5ee6ec6f4b09f47ea81118079a.tar.bz2
rails-b35339184671ef5ee6ec6f4b09f47ea81118079a.zip
Merge pull request #35286 from matthewdunbar/master
Properly handle cached queries with too many bind parameters
Diffstat (limited to 'activerecord/test/cases/bind_parameter_test.rb')
-rw-r--r--activerecord/test/cases/bind_parameter_test.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/activerecord/test/cases/bind_parameter_test.rb b/activerecord/test/cases/bind_parameter_test.rb
index 22a98036f3..ca97a5dc65 100644
--- a/activerecord/test/cases/bind_parameter_test.rb
+++ b/activerecord/test/cases/bind_parameter_test.rb
@@ -44,6 +44,18 @@ if ActiveRecord::Base.connection.prepared_statements
assert_equal 0, topics.count
end
+ def test_too_many_binds_with_query_cache
+ Topic.connection.enable_query_cache!
+ bind_params_length = @connection.send(:bind_params_length)
+ topics = Topic.where(id: (1 .. bind_params_length + 1).to_a)
+ assert_equal Topic.count, topics.count
+
+ topics = Topic.where.not(id: (1 .. bind_params_length + 1).to_a)
+ assert_equal 0, topics.count
+ ensure
+ Topic.connection.disable_query_cache!
+ end
+
def test_bind_from_join_in_subquery
subquery = Author.joins(:thinking_posts).where(name: "David")
scope = Author.from(subquery, "authors").where(id: 1)