Skip to content
Browse files

push column initialization down to the factory method

  • Loading branch information...
1 parent b8a533d commit d43edf6718e4b0fe2eb144adc6c2c39f15fcd92f @tenderlove tenderlove committed Mar 16, 2013
Showing with 13 additions and 13 deletions.
  1. +13 −13 activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb
View
26 activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb
@@ -218,17 +218,7 @@ def column(name, type, options = {})
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[name] ||= new_column_definition(name, type)
-
- limit = options.fetch(:limit) do
- native[type][:limit] if native[type].is_a?(Hash)
- end
-
- column.limit = limit
- column.precision = options[:precision]
- column.scale = options[:scale]
- column.default = options[:default]
- column.null = options[:null]
+ @columns_hash[name] ||= new_column_definition(name, type, options)
self
end
@@ -277,8 +267,18 @@ def create_column_definition(name, type)
ColumnDefinition.new name, type
end
- def new_column_definition(name, type)
- create_column_definition name, type
+ def new_column_definition(name, type, options)
+ column = create_column_definition name, type
+ limit = options.fetch(:limit) do
+ native[type][:limit] if native[type].is_a?(Hash)
+ end
+
+ column.limit = limit
+ column.precision = options[:precision]
+ column.scale = options[:scale]
+ column.default = options[:default]
+ column.null = options[:null]
+ column
end
def primary_key_column_name

0 comments on commit d43edf6

Please sign in to comment.
Something went wrong with that request. Please try again.