aboutsummaryrefslogtreecommitdiffstats
path: root/lib/arel/algebra/relations/utilities/externalization.rb
blob: 8e97573f68d9130a8c7268bf666eacbd60c87218 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
module Arel
  class Externalization < Compound
    include Recursion::BaseCase

    def == other
      super || Externalization === other && relation == other.relation
    end

    def wheres
      []
    end

    def attributes
      @attributes ||= Header.new(relation.attributes.map { |a| a.to_attribute(self) })
    end

    def table_sql(formatter = Sql::TableReference.new(relation))
      formatter.select relation.compiler.select_sql, self
    end

    # REMOVEME
    def name
      relation.name + '_external'
    end
  end
end