diff options
author | Michael Koziarski <michael@koziarski.com> | 2007-10-25 06:42:05 +0000 |
---|---|---|
committer | Michael Koziarski <michael@koziarski.com> | 2007-10-25 06:42:05 +0000 |
commit | 2d208eb3a09bf5b091464b7a4bbd00647eb7dfb2 (patch) | |
tree | b20f2f43f2341cca157320c56335ded5f72bc45f /activerecord/lib | |
parent | 12d8d48b7132e0467b477e6a88931840188f6c61 (diff) | |
download | rails-2d208eb3a09bf5b091464b7a4bbd00647eb7dfb2.tar.gz rails-2d208eb3a09bf5b091464b7a4bbd00647eb7dfb2.tar.bz2 rails-2d208eb3a09bf5b091464b7a4bbd00647eb7dfb2.zip |
Make sure that the Schema Dumper supports non-standard primary keys with MySQL. Closes #9971 [RubyRedRick]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8012 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib')
-rwxr-xr-x | activerecord/lib/active_record/connection_adapters/mysql_adapter.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb b/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb index 65faa80065..5242151736 100755 --- a/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb @@ -440,6 +440,16 @@ module ActiveRecord variables.first['Value'] unless variables.empty? end + # Returns a table's primary key and belonging sequence. + def pk_and_sequence_for(table) #:nodoc: + table_desc_result = execute("describe #{table}") + keys = [] + execute("describe #{table}").each_hash do |h| + keys << h["Field"]if h["Key"] == "PRI" + end + keys.length == 1 ? [keys.first, nil] : nil + end + private def connect encoding = @config[:encoding] |