diff options
author | Azzurrio <just.azzurri@gmail.com> | 2016-02-12 22:31:48 +0200 |
---|---|---|
committer | Azzurrio <just.azzurri@gmail.com> | 2016-02-22 01:19:34 +0200 |
commit | babf5d1d2d08ab1e2be7d404f433f2789b416fe9 (patch) | |
tree | 7b2c8eb14b00a6ac9b9d699d3f79e9ce8aecbaac | |
parent | db9ef08a8da60fe28b64bfa0136e7549d526f24d (diff) | |
download | rails-babf5d1d2d08ab1e2be7d404f433f2789b416fe9.tar.gz rails-babf5d1d2d08ab1e2be7d404f433f2789b416fe9.tar.bz2 rails-babf5d1d2d08ab1e2be7d404f433f2789b416fe9.zip |
Fix NoMethodError preparable for Arel::Visitors in case prepared statements is falsy
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb | 2 | ||||
-rw-r--r-- | activerecord/test/cases/adapters/postgresql/prepared_statements_test.rb | 22 |
2 files changed, 23 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb b/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb index bb5119d64e..aa5ae15285 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb @@ -30,7 +30,7 @@ module ActiveRecord def select_all(arel, name = nil, binds = [], preparable: nil) arel, binds = binds_from_relation arel, binds sql = to_sql(arel, binds) - if arel.is_a?(String) && preparable.nil? + if !prepared_statements || (arel.is_a?(String) && preparable.nil?) preparable = false else preparable = visitor.preparable diff --git a/activerecord/test/cases/adapters/postgresql/prepared_statements_test.rb b/activerecord/test/cases/adapters/postgresql/prepared_statements_test.rb new file mode 100644 index 0000000000..f1519db48b --- /dev/null +++ b/activerecord/test/cases/adapters/postgresql/prepared_statements_test.rb @@ -0,0 +1,22 @@ +require "cases/helper" +require "models/developer" + +class PreparedStatementsTest < ActiveRecord::PostgreSQLTestCase + fixtures :developers + + def setup + @default_prepared_statements = Developer.connection_config[:prepared_statements] + Developer.connection_config[:prepared_statements] = false + end + + def teardown + Developer.connection_config[:prepared_statements] = @default_prepared_statements + end + + def nothing_raised_with_falsy_prepared_statements + assert_nothing_raised do + Developer.where(id: 1) + end + end + +end |