Skip to content

Commit c901fad

Browse files
committed
Merge pull request rails#22748 from Azzurrio/master
Fix NoMethodError preparable for Arel::Visitors::PostgreSQL
2 parents 3591a00 + babf5d1 commit c901fad

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def cacheable_query(arel) # :nodoc:
3030
def select_all(arel, name = nil, binds = [], preparable: nil)
3131
arel, binds = binds_from_relation arel, binds
3232
sql = to_sql(arel, binds)
33-
if arel.is_a?(String) && preparable.nil?
33+
if !prepared_statements || (arel.is_a?(String) && preparable.nil?)
3434
preparable = false
3535
else
3636
preparable = visitor.preparable
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
require "cases/helper"
2+
require "models/developer"
3+
4+
class PreparedStatementsTest < ActiveRecord::PostgreSQLTestCase
5+
fixtures :developers
6+
7+
def setup
8+
@default_prepared_statements = Developer.connection_config[:prepared_statements]
9+
Developer.connection_config[:prepared_statements] = false
10+
end
11+
12+
def teardown
13+
Developer.connection_config[:prepared_statements] = @default_prepared_statements
14+
end
15+
16+
def nothing_raised_with_falsy_prepared_statements
17+
assert_nothing_raised do
18+
Developer.where(id: 1)
19+
end
20+
end
21+
22+
end

0 commit comments

Comments
 (0)