diff options
author | Matthew Draper <matthew@trebex.net> | 2016-02-22 22:33:25 +1030 |
---|---|---|
committer | Matthew Draper <matthew@trebex.net> | 2016-02-22 22:33:25 +1030 |
commit | c901fad42cb49ad5ac847b1159e38fdfe12ab76a (patch) | |
tree | 5031220894e2121f45fe7a134ee11b20a66a6e91 | |
parent | 3591a00ea60b46793b0ccf031948ef0ca0802c23 (diff) | |
parent | babf5d1d2d08ab1e2be7d404f433f2789b416fe9 (diff) | |
download | rails-c901fad42cb49ad5ac847b1159e38fdfe12ab76a.tar.gz rails-c901fad42cb49ad5ac847b1159e38fdfe12ab76a.tar.bz2 rails-c901fad42cb49ad5ac847b1159e38fdfe12ab76a.zip |
Merge pull request #22748 from Azzurrio/master
Fix NoMethodError preparable for Arel::Visitors::PostgreSQL
-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 |