Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

remove the bind substitution visitor. to_sql should never return bind…

… values
  • Loading branch information...
commit 1794ac0197501c8d416c37769f2b5683d297ce6f 1 parent a14f746
@tenderlove tenderlove authored
View
4 activerecord/lib/active_record/connection_adapters/abstract_adapter.rb
@@ -105,10 +105,6 @@ def initialize(connection, logger = nil, pool = nil) #:nodoc:
@prepared_statements = false
end
- def bind_substitution_visitor
- @bind_sub_visitor ||= visitor.dup.extend(Arel::Visitors::BindVisitor)
- end
-
def valid_type?(type)
true
end
View
11 activerecord/lib/active_record/relation.rb
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
+require 'arel/collectors/bind'
module ActiveRecord
# = Active Record Relation
@@ -512,17 +513,17 @@ def to_sql
@to_sql ||= begin
relation = self
connection = klass.connection
- visitor = connection.bind_substitution_visitor
+ visitor = connection.visitor
if eager_loading?
find_with_associations { |rel| relation = rel }
end
arel = relation.arel
- binds = arel.bind_values + relation.bind_values
- visitor.compile(arel.ast) do
- connection.quote(*binds.shift.reverse)
- end
+ binds = (arel.bind_values + relation.bind_values).dup
+ binds.map! { |bv| connection.quote(*bv.reverse) }
+ collect = visitor.accept(arel.ast, Arel::Collectors::Bind.new)
+ collect.substitute_binds(binds).join
end
end
View
4 activerecord/test/cases/relation/merging_test.rb
@@ -17,9 +17,7 @@ def test_relation_merging
end
def test_relation_to_sql
- sql = Post.connection.unprepared_statement do
- Post.first.comments.to_sql
- end
+ sql = Post.first.comments.to_sql
assert_no_match(/\?/, sql)
end
Please sign in to comment.
Something went wrong with that request. Please try again.