diff options
Diffstat (limited to 'lib/arel/engines/sql/relations/table.rb')
-rw-r--r-- | lib/arel/engines/sql/relations/table.rb | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/arel/engines/sql/relations/table.rb b/lib/arel/engines/sql/relations/table.rb index 8ee7a94357..7940fd781f 100644 --- a/lib/arel/engines/sql/relations/table.rb +++ b/lib/arel/engines/sql/relations/table.rb @@ -42,11 +42,14 @@ module Arel def attributes return @attributes if defined?(@attributes) if table_exists? - @attributes = columns.collect do |column| - Sql::Attributes.for(column).new(column, self, column.name.to_sym) + @attributes ||= begin + attrs = columns.collect do |column| + Sql::Attributes.for(column).new(column, self, column.name.to_sym) + end + Header.new(attrs) end else - [] + Header.new end end @@ -67,7 +70,8 @@ module Arel end def reset - @attributes = @columns = nil + @columns = nil + @attributes = Header.new([]) end def ==(other) |