aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/arel/nodes/table_alias.rb
blob: f95ca16a3dc9496ea6dee5ed08c1ddacbf6b20c6 (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
27
# frozen_string_literal: true

module Arel # :nodoc: all
  module Nodes
    class TableAlias < Arel::Nodes::Binary
      alias :name :right
      alias :relation :left
      alias :table_alias :name

      def [](name)
        Attribute.new(self, name)
      end

      def table_name
        relation.respond_to?(:name) ? relation.name : name
      end

      def type_cast_for_database(*args)
        relation.type_cast_for_database(*args)
      end

      def able_to_type_cast?
        relation.respond_to?(:able_to_type_cast?) && relation.able_to_type_cast?
      end
    end
  end
end