diff options
Diffstat (limited to 'lib/arel')
-rw-r--r-- | lib/arel/nodes/table_alias.rb | 8 | ||||
-rw-r--r-- | lib/arel/table.rb | 4 |
2 files changed, 4 insertions, 8 deletions
diff --git a/lib/arel/nodes/table_alias.rb b/lib/arel/nodes/table_alias.rb index 7ec1fad272..60da7b19f3 100644 --- a/lib/arel/nodes/table_alias.rb +++ b/lib/arel/nodes/table_alias.rb @@ -1,20 +1,16 @@ module Arel module Nodes class TableAlias - attr_reader :name, :relation, :columns + attr_reader :name, :relation alias :table_alias :name def initialize name, relation @name = name @relation = relation - @columns = relation.columns.map { |column| - column.dup.tap { |col| col.relation = self } - } end def [] name - name = name.to_sym - columns.find { |column| column.name == name } + Attribute.new self, name end end end diff --git a/lib/arel/table.rb b/lib/arel/table.rb index fe12427d1b..6f29a02e56 100644 --- a/lib/arel/table.rb +++ b/lib/arel/table.rb @@ -34,8 +34,8 @@ module Arel end end - def alias - Nodes::TableAlias.new("#{name}_2", self).tap do |node| + def alias name = "#{self.name}_2" + Nodes::TableAlias.new(name, self).tap do |node| @aliases << node end end |