diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-11-19 13:53:06 -0200 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-11-19 13:53:06 -0200 |
commit | e4300196721417237c3bfca0fc36313ea5ed7096 (patch) | |
tree | d8ff8cb7851fe38c58dd557fc6b2c51c7ec32688 /activerecord | |
parent | 75cfca0521f4e7ba983b5d2f2f23b95870880ea4 (diff) | |
parent | 995c697511a4e77fbe1e00793486ae07b18c5017 (diff) | |
download | rails-e4300196721417237c3bfca0fc36313ea5ed7096.tar.gz rails-e4300196721417237c3bfca0fc36313ea5ed7096.tar.bz2 rails-e4300196721417237c3bfca0fc36313ea5ed7096.zip |
Merge pull request #17662 from dtaniwaki/support-symbol-foreign-key-column-to-delete
Support symbol foreign key to delete
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb | 2 | ||||
-rw-r--r-- | activerecord/test/cases/migration/foreign_key_test.rb | 8 |
2 files changed, 9 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 cbf87df356..cc86c3776e 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb @@ -740,7 +740,7 @@ module ActiveRecord end fk_name_to_delete = options.fetch(:name) do - fk_to_delete = foreign_keys(from_table).detect {|fk| fk.column == options[:column] } + fk_to_delete = foreign_keys(from_table).detect {|fk| fk.column == options[:column].to_s } if fk_to_delete fk_to_delete.name diff --git a/activerecord/test/cases/migration/foreign_key_test.rb b/activerecord/test/cases/migration/foreign_key_test.rb index 52e963a14f..51e21528c2 100644 --- a/activerecord/test/cases/migration/foreign_key_test.rb +++ b/activerecord/test/cases/migration/foreign_key_test.rb @@ -162,6 +162,14 @@ module ActiveRecord assert_equal [], @connection.foreign_keys("astronauts") end + def test_remove_foreign_key_by_symbol_column + @connection.add_foreign_key :astronauts, :rockets, column: :rocket_id + + assert_equal 1, @connection.foreign_keys("astronauts").size + @connection.remove_foreign_key :astronauts, column: :rocket_id + assert_equal [], @connection.foreign_keys("astronauts") + end + def test_remove_foreign_key_by_name @connection.add_foreign_key :astronauts, :rockets, column: "rocket_id", name: "fancy_named_fk" |