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

Consistently use visitor.compile

This commit is contained in:
Ryuta Kamizono 2018-09-09 01:55:26 +09:00
parent b691c21475
commit fc173b0a24
2 changed files with 5 additions and 5 deletions

View file

@ -20,7 +20,7 @@ module ActiveRecord
raise "Passing bind parameters with an arel AST is forbidden. " \ raise "Passing bind parameters with an arel AST is forbidden. " \
"The values must be stored on the AST directly" "The values must be stored on the AST directly"
end end
sql, binds = visitor.accept(arel_or_sql_string.ast, collector).value sql, binds = visitor.compile(arel_or_sql_string.ast, collector)
[sql.freeze, binds || []] [sql.freeze, binds || []]
else else
[arel_or_sql_string.dup.freeze, binds] [arel_or_sql_string.dup.freeze, binds]
@ -32,11 +32,11 @@ module ActiveRecord
# can be used to query the database repeatedly. # can be used to query the database repeatedly.
def cacheable_query(klass, arel) # :nodoc: def cacheable_query(klass, arel) # :nodoc:
if prepared_statements if prepared_statements
sql, binds = visitor.accept(arel.ast, collector).value sql, binds = visitor.compile(arel.ast, collector)
query = klass.query(sql) query = klass.query(sql)
else else
collector = PartialQueryCollector.new collector = PartialQueryCollector.new
parts, binds = visitor.accept(arel.ast, collector).value parts, binds = visitor.compile(arel.ast, collector)
query = klass.partial_query(parts) query = klass.partial_query(parts)
end end
[query, binds] [query, binds]

View file

@ -67,8 +67,8 @@ module Arel # :nodoc: all
@connection = connection @connection = connection
end end
def compile(node, &block) def compile(node, collector = Arel::Collectors::SQLString.new, &block)
accept(node, Arel::Collectors::SQLString.new, &block).value accept(node, collector, &block).value
end end
private private