aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2013-03-16 15:08:49 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2013-03-22 16:22:00 -0700
commitb8a533d5f16de5c9df59a9275a1f15d49f1b0256 (patch)
tree7dd05b7a48c9f7218aa6691dab166a29a0be63b2 /activerecord/lib
parentc5e03e87eeb100900ce6c87bc5a1977d36f74522 (diff)
downloadrails-b8a533d5f16de5c9df59a9275a1f15d49f1b0256.tar.gz
rails-b8a533d5f16de5c9df59a9275a1f15d49f1b0256.tar.bz2
rails-b8a533d5f16de5c9df59a9275a1f15d49f1b0256.zip
@columns list is no longer necessary
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb12
1 files changed, 4 insertions, 8 deletions
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)