diff options
author | Akira Matsuda <ronnie@dio.jp> | 2012-04-19 22:04:13 +0900 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2012-04-19 06:46:18 -0700 |
commit | f51557deb0a591a442e94d07d90e57853693ad14 (patch) | |
tree | 0e3c644daa401921922d2dea4cd08c1c8526b958 /activerecord/lib | |
parent | b9e5c5aca3313bd67b35a608c504175f99172d7f (diff) | |
download | rails-f51557deb0a591a442e94d07d90e57853693ad14.tar.gz rails-f51557deb0a591a442e94d07d90e57853693ad14.tar.bz2 rails-f51557deb0a591a442e94d07d90e57853693ad14.zip |
Be sure to correctly fetch PK name from MySQL even if the PK has some custom option
Backports #5900
Conflicts:
activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb
activerecord/test/cases/adapters/mysql/mysql_adapter_test.rb
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb b/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb index d3f5600119..2658c444d1 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb @@ -525,7 +525,7 @@ module ActiveRecord def pk_and_sequence_for(table) execute_and_free("SHOW CREATE TABLE #{quote_table_name(table)}", 'SCHEMA') do |result| create_table = each_hash(result).first[:"Create Table"] - if create_table.to_s =~ /PRIMARY KEY\s+\((.+)\)/ + if create_table.to_s =~ /PRIMARY KEY\s+(?:USING\s+\w+\s+)?\((.+)\)/ keys = $1.split(",").map { |key| key.gsub(/[`"]/, "") } keys.length == 1 ? [keys.first, nil] : nil else |