aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorRafael França <rafaelmfranca@gmail.com>2018-11-13 15:37:51 -0500
committerGitHub <noreply@github.com>2018-11-13 15:37:51 -0500
commit5e9a3e7763673c0e5f58bdfbe2263d135198e9d7 (patch)
treecf25d69e5ac58605b9fec61e8b8833e7b9dda33b /activerecord
parent7a954211e6ffe9b482fbd65711edadbb265bf1a7 (diff)
parent31efa2d9e1e73ad5d5022a69fda8f46c7c8c2b04 (diff)
downloadrails-5e9a3e7763673c0e5f58bdfbe2263d135198e9d7.tar.gz
rails-5e9a3e7763673c0e5f58bdfbe2263d135198e9d7.tar.bz2
rails-5e9a3e7763673c0e5f58bdfbe2263d135198e9d7.zip
Merge pull request #34436 from gmcgibbon/fix_default_max_bind_length_sqlite
Adjust bind length of SQLite to default (999)
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb6
-rw-r--r--activerecord/test/cases/adapters/sqlite3/bind_parameter_test.rb20
2 files changed, 26 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb b/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb
index e0355a316b..3312c3de01 100644
--- a/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb
+++ b/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb
@@ -396,6 +396,12 @@ module ActiveRecord
end
private
+ # See https://www.sqlite.org/limits.html,
+ # the default value is 999 when not configured.
+ def bind_params_length
+ 999
+ end
+
def check_version
if sqlite_version < "3.8.0"
raise "Your version of SQLite (#{sqlite_version}) is too old. Active Record supports SQLite >= 3.8."
diff --git a/activerecord/test/cases/adapters/sqlite3/bind_parameter_test.rb b/activerecord/test/cases/adapters/sqlite3/bind_parameter_test.rb
new file mode 100644
index 0000000000..93a7dafebd
--- /dev/null
+++ b/activerecord/test/cases/adapters/sqlite3/bind_parameter_test.rb
@@ -0,0 +1,20 @@
+# frozen_string_literal: true
+
+require "cases/helper"
+require "models/topic"
+
+module ActiveRecord
+ module ConnectionAdapters
+ class SQLite3Adapter
+ class BindParameterTest < ActiveRecord::SQLite3TestCase
+ def test_too_many_binds
+ topics = Topic.where(id: (1..999).to_a << 2**63)
+ assert_equal Topic.count, topics.count
+
+ topics = Topic.where.not(id: (1..999).to_a << 2**63)
+ assert_equal 0, topics.count
+ end
+ end
+ end
+ end
+end