1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/lib/arel/visitors/join_sql.rb
2010-08-24 18:13:01 -07:00

25 lines
740 B
Ruby

module Arel
module Visitors
###
# This class produces SQL for JOIN clauses but omits the "single-source"
# part of the Join grammar:
#
# http://www.sqlite.org/syntaxdiagrams.html#join-source
#
# This visitor is used in SelectManager#join_sql and is for backwards
# compatibility with Arel V1.0
class JoinSql < Arel::Visitors::ToSql
def visit_Arel_Nodes_SelectCore o
o.froms.grep(Nodes::Join).map { |x| visit x }.join ', '
end
def visit_Arel_Nodes_OuterJoin o
"OUTER JOIN #{visit o.right} #{visit o.constraint}"
end
def visit_Arel_Nodes_InnerJoin o
"INNER JOIN #{visit o.right} #{visit o.constraint if o.constraint}"
end
end
end
end