aboutsummaryrefslogtreecommitdiffstats
path: root/lib/arel/visitors/join_sql.rb
blob: 95b27b44761a6cf8e70a6b53a56d7e4bd9544d33 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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_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