From fc173b0a2452dcaa527fd21d264ba2296d4fa72a Mon Sep 17 00:00:00 2001 From: Ryuta Kamizono Date: Sun, 9 Sep 2018 01:55:26 +0900 Subject: [PATCH] Consistently use `visitor.compile` --- .../connection_adapters/abstract/database_statements.rb | 6 +++--- activerecord/lib/arel/visitors/to_sql.rb | 4 ++-- 2 files changed, 5 insertions(+), 5 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 1d36c3c8b1..fdc9ffa688 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb @@ -20,7 +20,7 @@ module ActiveRecord raise "Passing bind parameters with an arel AST is forbidden. " \ "The values must be stored on the AST directly" 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 || []] else [arel_or_sql_string.dup.freeze, binds] @@ -32,11 +32,11 @@ module ActiveRecord # can be used to query the database repeatedly. def cacheable_query(klass, arel) # :nodoc: if prepared_statements - sql, binds = visitor.accept(arel.ast, collector).value + sql, binds = visitor.compile(arel.ast, collector) query = klass.query(sql) else collector = PartialQueryCollector.new - parts, binds = visitor.accept(arel.ast, collector).value + parts, binds = visitor.compile(arel.ast, collector) query = klass.partial_query(parts) end [query, binds] diff --git a/activerecord/lib/arel/visitors/to_sql.rb b/activerecord/lib/arel/visitors/to_sql.rb index 5986fd5576..0682c066fb 100644 --- a/activerecord/lib/arel/visitors/to_sql.rb +++ b/activerecord/lib/arel/visitors/to_sql.rb @@ -67,8 +67,8 @@ module Arel # :nodoc: all @connection = connection end - def compile(node, &block) - accept(node, Arel::Collectors::SQLString.new, &block).value + def compile(node, collector = Arel::Collectors::SQLString.new, &block) + accept(node, collector, &block).value end private