diff options
author | Piotr Sarnacki <drogus@gmail.com> | 2012-05-01 16:10:34 -0700 |
---|---|---|
committer | Piotr Sarnacki <drogus@gmail.com> | 2012-05-02 11:47:06 -0700 |
commit | 02ca9151a043a4fefbb3f22edd05f0cd392fffaa (patch) | |
tree | 48f57a3542bc20593e83e1ce97591b682d3461bc /activerecord/lib/active_record | |
parent | 5fe88b11f11bb3b30bc23c57b36be4f027d915ba (diff) | |
download | rails-02ca9151a043a4fefbb3f22edd05f0cd392fffaa.tar.gz rails-02ca9151a043a4fefbb3f22edd05f0cd392fffaa.tar.bz2 rails-02ca9151a043a4fefbb3f22edd05f0cd392fffaa.zip |
Deprecate remove_column with array as an argument
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb | 6 | ||||
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb | 7 |
2 files changed, 13 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb index a0e2900120..c3aba63e1c 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb @@ -269,6 +269,12 @@ module ActiveRecord # remove_column(:suppliers, :qualification) # remove_columns(:suppliers, :qualification, :experience) def remove_column(table_name, *column_names) + if column_names.first.kind_of?(Enumerable) + message = 'Passing array to remove_columns is deprecated, please use ' + + 'multiple arguments, like: `remove_columns(:posts, :foo, :bar)`' + ActiveSupport::Deprecation.warn message, caller + end + columns_for_remove(table_name, *column_names).each {|column_name| execute "ALTER TABLE #{quote_table_name(table_name)} DROP #{column_name}" } end alias :remove_columns :remove_column diff --git a/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb b/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb index 55bffc6518..91929f80d2 100644 --- a/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb @@ -407,6 +407,13 @@ module ActiveRecord def remove_column(table_name, *column_names) #:nodoc: raise ArgumentError.new("You must specify at least one column name. Example: remove_column(:people, :first_name)") if column_names.empty? + + if column_names.first.kind_of?(Enumerable) + message = 'Passing array to remove_columns is deprecated, please use ' + + 'multiple arguments, like: `remove_columns(:posts, :foo, :bar)`' + ActiveSupport::Deprecation.warn message, caller + end + column_names.flatten.each do |column_name| alter_table(table_name) do |definition| definition.columns.delete(definition[column_name]) |