1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Fix NoMethodError preparable for Arel::Visitors in case prepared statements is falsy

This commit is contained in:
Azzurrio 2016-02-12 22:31:48 +02:00
parent db9ef08a8d
commit babf5d1d2d
2 changed files with 23 additions and 1 deletions

View file

@ -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

View file

@ -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