diff options
author | Hongli Lai (Phusion) <hongli@phusion.nl> | 2009-07-05 09:59:25 +0200 |
---|---|---|
committer | Yehuda Katz <wycats@yehuda-katzs-macbookpro41.local> | 2009-07-07 16:17:25 -0700 |
commit | 187d90f7529e02c3c863e6b68b45d8e34f315140 (patch) | |
tree | 2e888155ab463ea6dda8824bae923c0598ca945d /activerecord/lib/active_record | |
parent | 1e2d7229602f467cfdc0ef606b5ef8a5566a1501 (diff) | |
download | rails-187d90f7529e02c3c863e6b68b45d8e34f315140.tar.gz rails-187d90f7529e02c3c863e6b68b45d8e34f315140.tar.bz2 rails-187d90f7529e02c3c863e6b68b45d8e34f315140.zip |
Add support for dumping non-standard primary keys when using the SQLite3 adapter. Fix unit tests so that this feature is tested for all adapters. [#2868 state:resolved]
Signed-off-by: Yehuda Katz <wycats@yehuda-katzs-macbookpro41.local>
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/schema_dumper.rb | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/schema_dumper.rb b/activerecord/lib/active_record/schema_dumper.rb index 2d90ef35aa..5d88012e4f 100644 --- a/activerecord/lib/active_record/schema_dumper.rb +++ b/activerecord/lib/active_record/schema_dumper.rb @@ -78,11 +78,14 @@ HEADER begin tbl = StringIO.new + # first dump primary key column if @connection.respond_to?(:pk_and_sequence_for) pk, pk_seq = @connection.pk_and_sequence_for(table) + elsif @connection.respond_to?(:primary_key) + pk = @connection.primary_key(table) end pk ||= 'id' - + tbl.print " create_table #{table.inspect}" if columns.detect { |c| c.name == pk } if pk != 'id' @@ -94,6 +97,7 @@ HEADER tbl.print ", :force => true" tbl.puts " do |t|" + # then dump all non-primary key columns column_specs = columns.map do |column| raise StandardError, "Unknown type '#{column.sql_type}' for column '#{column.name}'" if @types[column.type].nil? next if column.name == pk |