diff options
Diffstat (limited to 'activerecord/lib/arel/visitors/where_sql.rb')
-rw-r--r-- | activerecord/lib/arel/visitors/where_sql.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/activerecord/lib/arel/visitors/where_sql.rb b/activerecord/lib/arel/visitors/where_sql.rb new file mode 100644 index 0000000000..55e6ca9a21 --- /dev/null +++ b/activerecord/lib/arel/visitors/where_sql.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true +module Arel + module Visitors + class WhereSql < Arel::Visitors::ToSql + def initialize(inner_visitor, *args, &block) + @inner_visitor = inner_visitor + super(*args, &block) + end + + private + + def visit_Arel_Nodes_SelectCore o, collector + collector << "WHERE " + wheres = o.wheres.map do |where| + Nodes::SqlLiteral.new(@inner_visitor.accept(where, collector.class.new).value) + end + + inject_join wheres, collector, ' AND ' + end + end + end +end |