From b8a533d5f16de5c9df59a9275a1f15d49f1b0256 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Sat, 16 Mar 2013 15:08:49 -0700 Subject: @columns list is no longer necessary --- .../connection_adapters/abstract/schema_definitions.rb | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'activerecord/lib/active_record') diff --git a/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb b/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb index 57bc4da5cc..53589ab958 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb @@ -48,11 +48,10 @@ module ActiveRecord class TableDefinition # An array of ColumnDefinition objects, representing the column changes # that have been defined. - attr_accessor :columns, :indexes + attr_accessor :indexes attr_reader :name, :temporary, :options def initialize(types, name, temporary, options) - @columns = [] @columns_hash = {} @indexes = {} @native = types @@ -61,6 +60,8 @@ module ActiveRecord @name = name end + def columns; @columns_hash.values; end + # Appends a primary key definition to the table definition. # Can be called multiple times, but this is probably not a good idea. def primary_key(name) @@ -217,12 +218,7 @@ module ActiveRecord raise ArgumentError, "you can't redefine the primary key column '#{name}'. To define a custom primary key, pass { id: false } to create_table." end - column = @columns_hash.fetch(name) { - col = new_column_definition(name, type) - @columns << col - @columns_hash[name] = col - col - } + column = @columns_hash[name] ||= new_column_definition(name, type) limit = options.fetch(:limit) do native[type][:limit] if native[type].is_a?(Hash) -- cgit v1.2.3