Sha256: 2ab939f8a5f2be39caff325e2b7a74a021e9f285aa39ca523ffc3c02386f901f

Contents?: true

Size: 1.1 KB

Versions: 13

Compression:

Stored size: 1.1 KB

Contents

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
      private

      def visit_Arel_Nodes_SelectCore o
        [o.froms].grep(Nodes::Join).map { |x| visit x }.join ', '
      end

      def visit_Arel_Nodes_StringJoin o
        [
          (visit o.left if Nodes::Join === o.left),
          visit(o.right)
        ].compact.join ' '
      end

      def visit_Arel_Nodes_OuterJoin o
        [
          (visit o.left if Nodes::Join === o.left),
          "LEFT OUTER JOIN #{visit o.right} #{visit o.constraint if o.constraint}"
        ].compact.join ' '
      end

      def visit_Arel_Nodes_InnerJoin o
        [
          (visit o.left if Nodes::Join === o.left),
          "INNER JOIN #{visit o.right} #{visit o.constraint if o.constraint}"
        ].compact.join ' '
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
arel-2.0.10 lib/arel/visitors/join_sql.rb
square-arel-2.0.9.20110222133018 lib/arel/visitors/join_sql.rb
arel-2.0.9 lib/arel/visitors/join_sql.rb
arel-2.0.9.rc1 lib/arel/visitors/join_sql.rb
arel-2.0.8 lib/arel/visitors/join_sql.rb
arel-2.0.8.beta.20110131120940 lib/arel/visitors/join_sql.rb
arel-2.0.7 lib/arel/visitors/join_sql.rb
arel-2.0.7.beta.20110110114925 lib/arel/visitors/join_sql.rb
arel-2.0.6 lib/arel/visitors/join_sql.rb
arel-2.0.5 lib/arel/visitors/join_sql.rb
arel-2.0.4 lib/arel/visitors/join_sql.rb
arel-2.0.3 lib/arel/visitors/join_sql.rb
arel-2.0.2 lib/arel/visitors/join_sql.rb