aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2011-06-18 19:34:39 -0700
committerJosé Valim <jose.valim@gmail.com>2011-06-18 19:34:39 -0700
commit7d4606156b9d2b1900e99b9fb5cd08529b8f95a0 (patch)
tree15de4a53c7a1e097872b899bb0f9b8d9fbff90a2 /activerecord
parent4054435b28d0abbad0278dbdec3d432a284c8959 (diff)
parent3cc83a8f24ba61b648a2728efc113388cf1ec243 (diff)
downloadrails-7d4606156b9d2b1900e99b9fb5cd08529b8f95a0.tar.gz
rails-7d4606156b9d2b1900e99b9fb5cd08529b8f95a0.tar.bz2
rails-7d4606156b9d2b1900e99b9fb5cd08529b8f95a0.zip
Merge pull request #1763 from grantneufeld/schema_column_exists_options_hash
Fix default options argument on ActiveRecord::ConnectionAdaptors::Table#column_exists?
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb2
-rw-r--r--activerecord/test/cases/migration_test.rb12
2 files changed, 13 insertions, 1 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 a9e3c83eb0..82f564e41d 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb
@@ -328,7 +328,7 @@ module ActiveRecord
end
# Checks to see if a column exists. See SchemaStatements#column_exists?
- def column_exists?(column_name, type = nil, options = nil)
+ def column_exists?(column_name, type = nil, options = {})
@base.column_exists?(@table_name, column_name, type, options)
end
diff --git a/activerecord/test/cases/migration_test.rb b/activerecord/test/cases/migration_test.rb
index bf7565a0d0..93a1249e43 100644
--- a/activerecord/test/cases/migration_test.rb
+++ b/activerecord/test/cases/migration_test.rb
@@ -1071,6 +1071,18 @@ if ActiveRecord::Base.connection.supports_migrations?
Person.connection.drop_table :testings rescue nil
end
+ def test_column_exists_on_table_with_no_options_parameter_supplied
+ Person.connection.create_table :testings do |t|
+ t.string :foo
+ end
+ Person.connection.change_table :testings do |t|
+ assert t.column_exists?(:foo)
+ assert !(t.column_exists?(:bar))
+ end
+ ensure
+ Person.connection.drop_table :testings rescue nil
+ end
+
def test_add_table
assert !Reminder.table_exists?