diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2013-03-16 15:17:05 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2013-03-22 16:22:00 -0700 |
commit | d43edf6718e4b0fe2eb144adc6c2c39f15fcd92f (patch) | |
tree | bad49c474592e10898a8da4666eab9eeb790ce52 /activerecord/lib/active_record/connection_adapters | |
parent | b8a533d5f16de5c9df59a9275a1f15d49f1b0256 (diff) | |
download | rails-d43edf6718e4b0fe2eb144adc6c2c39f15fcd92f.tar.gz rails-d43edf6718e4b0fe2eb144adc6c2c39f15fcd92f.tar.bz2 rails-d43edf6718e4b0fe2eb144adc6c2c39f15fcd92f.zip |
push column initialization down to the factory method
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb | 26 |
1 files changed, 13 insertions, 13 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 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 |