aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/CHANGELOG.md2
-rw-r--r--activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb6
-rw-r--r--activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb7
-rw-r--r--activerecord/test/cases/migration_test.rb6
4 files changed, 20 insertions, 1 deletions
diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md
index ffd74893be..2f4a0873b0 100644
--- a/activerecord/CHANGELOG.md
+++ b/activerecord/CHANGELOG.md
@@ -4,7 +4,7 @@
This could cause infinite recursion and potentially other problems.
See GH #5667. *Jon Leighton*
-## Rails 3.2.3 (unreleased) ##
+## Rails 3.2.3 (March 30, 2012) ##
* Added find_or_create_by_{attribute}! dynamic method. *Andrew White*
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])
diff --git a/activerecord/test/cases/migration_test.rb b/activerecord/test/cases/migration_test.rb
index 5c5c872993..8dde6c6b5a 100644
--- a/activerecord/test/cases/migration_test.rb
+++ b/activerecord/test/cases/migration_test.rb
@@ -873,6 +873,12 @@ if ActiveRecord::Base.connection.supports_migrations?
assert_raise(ArgumentError) { Person.connection.remove_column("funny") }
end
+ def test_remove_column_with_array_as_an_argument_is_deprecated
+ assert_deprecated /Passing array to remove_columns is deprecated/ do
+ Person.connection.remove_column("people", ["last_name", "description"])
+ end
+ end
+
def test_change_type_of_not_null_column
assert_nothing_raised do
Topic.connection.change_column "topics", "written_on", :datetime, :null => false