aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorAleksey Magusev <lexmag@gmail.com>2012-06-30 02:23:20 +0400
committerAleksey Magusev <lexmag@gmail.com>2012-06-30 22:12:16 +0400
commit59e23e2ff22c0deb770af768c4cc04bd1b2c2ad7 (patch)
treec5c8bea7287f9d98f47fbe9b91539106ada4700b /activerecord/lib
parentd79ca9288e5c55563a554d05c779a41e701181cd (diff)
downloadrails-59e23e2ff22c0deb770af768c4cc04bd1b2c2ad7.tar.gz
rails-59e23e2ff22c0deb770af768c4cc04bd1b2c2ad7.tar.bz2
rails-59e23e2ff22c0deb770af768c4cc04bd1b2c2ad7.zip
Add more options to column_exists? method
Also fix failures in check options for nil
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb10
1 files changed, 6 insertions, 4 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 f5794a4e54..2b0ba2f479 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
@@ -68,10 +68,12 @@ module ActiveRecord
# column_exists?(:suppliers, :name, :string, :limit => 100)
def column_exists?(table_name, column_name, type = nil, options = {})
columns(table_name).any?{ |c| c.name == column_name.to_s &&
- (!type || c.type == type) &&
- (!options[:limit] || c.limit == options[:limit]) &&
- (!options[:precision] || c.precision == options[:precision]) &&
- (!options[:scale] || c.scale == options[:scale]) }
+ (!type || c.type == type) &&
+ (!options.key?(:limit) || c.limit == options[:limit]) &&
+ (!options.key?(:precision) || c.precision == options[:precision]) &&
+ (!options.key?(:scale) || c.scale == options[:scale]) &&
+ (!options.key?(:default) || c.default == options[:default]) &&
+ (!options.key?(:null) || c.null == options[:null]) }
end
# Creates a new table with the name +table_name+. +table_name+ may either