Changeset 8012
- Timestamp:
- 10/25/07 06:42:05 (1 year ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb
r7980 r8012 441 441 end 442 442 443 # Returns a table's primary key and belonging sequence. 444 def pk_and_sequence_for(table) #:nodoc: 445 table_desc_result = execute("describe #{table}") 446 keys = [] 447 execute("describe #{table}").each_hash do |h| 448 keys << h["Field"]if h["Key"] == "PRI" 449 end 450 keys.length == 1 ? [keys.first, nil] : nil 451 end 452 443 453 private 444 454 def connect trunk/activerecord/test/schema_dumper_test.rb
r7405 r8012 111 111 assert_match %r{t.text\s+"body",\s+:default => "",\s+:null => false$}, output 112 112 end 113 114 def test_mysql_schema_dump_should_honor_nonstandard_primary_keys 115 output = standard_dump 116 match = output.match(%r{create_table "movies"(.*)do}) 117 assert_not_nil(match, "nonstandardpk table not found") 118 assert_match %r(:primary_key => "movieid"), match[1], "non-standard primary key not preserved" 119 end 113 120 end 114 121