aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/bind_parameter_test.rb
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2018-09-14 06:57:20 +0900
committerRyuta Kamizono <kamipo@gmail.com>2018-09-14 07:00:45 +0900
commitb571c4f3f2811b5d3dc8b005707cf8c353abdf03 (patch)
tree66b732ce2db834abc02aa1f4c0cb6d356d2e8edd /activerecord/test/cases/bind_parameter_test.rb
parent18303838335214771ffce2e881ff8eb9f8247dbe (diff)
downloadrails-b571c4f3f2811b5d3dc8b005707cf8c353abdf03.tar.gz
rails-b571c4f3f2811b5d3dc8b005707cf8c353abdf03.tar.bz2
rails-b571c4f3f2811b5d3dc8b005707cf8c353abdf03.zip
Fallback to unprepared statement only when bind params limit is exceeded
This is a follow up and/or an alternative of #33844. Unlike #33844, this would attempt to construct unprepared statement only when bind params limit (mysql2 65535, pg 65535, sqlite3 249999) is exceeded. I only defined 65535 as the limit, not defined 249999 for sqlite3, since it is an edge case, I'm not excited to add less worth extra code.
Diffstat (limited to 'activerecord/test/cases/bind_parameter_test.rb')
-rw-r--r--activerecord/test/cases/bind_parameter_test.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/activerecord/test/cases/bind_parameter_test.rb b/activerecord/test/cases/bind_parameter_test.rb
index 91cc49385c..9c1f7aaef2 100644
--- a/activerecord/test/cases/bind_parameter_test.rb
+++ b/activerecord/test/cases/bind_parameter_test.rb
@@ -34,6 +34,12 @@ if ActiveRecord::Base.connection.prepared_statements
ActiveSupport::Notifications.unsubscribe(@subscription)
end
+ def test_too_many_binds
+ 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
+ end
+
def test_bind_from_join_in_subquery
subquery = Author.joins(:thinking_posts).where(name: "David")
scope = Author.from(subquery, "authors").where(id: 1)