From d43edf6718e4b0fe2eb144adc6c2c39f15fcd92f Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Sat, 16 Mar 2013 15:17:05 -0700 Subject: push column initialization down to the factory method --- .../abstract/schema_definitions.rb | 26 +++++++++++----------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'activerecord/lib/active_record/connection_adapters') 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 53589ab958..fe381bcf01 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb @@ -218,17 +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[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 @@ module ActiveRecord 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 -- cgit v1.2.3