1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Merge pull request #4843 from seamusabshere/patch-1

Possibly clearer way of getting rid of ` and "
This commit is contained in:
Xavier Noria 2012-03-28 16:01:05 -07:00
commit bbd2caeaf9

View file

@ -526,7 +526,7 @@ module ActiveRecord
execute_and_free("SHOW CREATE TABLE #{quote_table_name(table)}", 'SCHEMA') do |result| execute_and_free("SHOW CREATE TABLE #{quote_table_name(table)}", 'SCHEMA') do |result|
create_table = each_hash(result).first[:"Create Table"] create_table = each_hash(result).first[:"Create Table"]
if create_table.to_s =~ /PRIMARY KEY\s+\((.+)\)/ if create_table.to_s =~ /PRIMARY KEY\s+\((.+)\)/
keys = $1.split(",").map { |key| key.gsub(/[`"]/, "") } keys = $1.split(",").map { |key| key.delete('`"') }
keys.length == 1 ? [keys.first, nil] : nil keys.length == 1 ? [keys.first, nil] : nil
else else
nil nil