diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2019-01-24 19:02:44 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2019-01-24 19:02:44 +0900 |
commit | 1fecebae31029cf2287f2bae88e8730f00569778 (patch) | |
tree | bb0e4e76c09dc08c8726ba0b5b2d1e969e6b2e6e /activerecord/lib | |
parent | 4a40128a3fdc66e9ae1af1b2869d936242f608a8 (diff) | |
download | rails-1fecebae31029cf2287f2bae88e8730f00569778.tar.gz rails-1fecebae31029cf2287f2bae88e8730f00569778.tar.bz2 rails-1fecebae31029cf2287f2bae88e8730f00569778.zip |
Allow `column_exists?` to be passed `type` argument as a string
Currently `conn.column_exists?("testings", "created_at", "datetime")`
returns false even if the table has the `created_at` column.
That reason is that `column.type` is a symbol but passed `type` is not
normalized to symbol unlike `column_name`, it is surprising behavior to
me.
I've improved that to normalize a value before comparison.
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb | 2 |
1 files changed, 1 insertions, 1 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 208c8c9c64..90a130320b 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb @@ -134,7 +134,7 @@ module ActiveRecord column_name = column_name.to_s checks = [] checks << lambda { |c| c.name == column_name } - checks << lambda { |c| c.type == type } if type + checks << lambda { |c| c.type == type.to_sym rescue nil } if type column_options_keys.each do |attr| checks << lambda { |c| c.send(attr) == options[attr] } if options.key?(attr) end |