aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/test')
-rw-r--r--activerecord/test/cases/copy_table_test_sqlite.rb11
-rw-r--r--activerecord/test/schema/schema.rb5
2 files changed, 16 insertions, 0 deletions
diff --git a/activerecord/test/cases/copy_table_test_sqlite.rb b/activerecord/test/cases/copy_table_test_sqlite.rb
index f0cfb67866..72bd7e2dab 100644
--- a/activerecord/test/cases/copy_table_test_sqlite.rb
+++ b/activerecord/test/cases/copy_table_test_sqlite.rb
@@ -46,6 +46,17 @@ class CopyTableTest < ActiveRecord::TestCase
test_copy_table('developers_projects', 'programmers_projects')
end
+ def test_copy_table_with_id_col_that_is_not_primary_key
+ test_copy_table('goofy_string_id', 'goofy_string_id2') do |from, to, options|
+ original_id = @connection.columns('goofy_string_id').detect{|col| col.name == 'id' }
+ copied_id = @connection.columns('goofy_string_id2').detect{|col| col.name == 'id' }
+ assert_equal original_id.type, copied_id.type
+ assert_equal original_id.sql_type, copied_id.sql_type
+ assert_equal original_id.limit, copied_id.limit
+ assert_equal original_id.primary, copied_id.primary
+ end
+ end
+
protected
def copy_table(from, to, options = {})
@connection.copy_table(from, to, {:temporary => true}.merge(options))
diff --git a/activerecord/test/schema/schema.rb b/activerecord/test/schema/schema.rb
index 094932d375..d44faf04cc 100644
--- a/activerecord/test/schema/schema.rb
+++ b/activerecord/test/schema/schema.rb
@@ -154,6 +154,11 @@ ActiveRecord::Schema.define do
t.string :name
end
+ create_table :goofy_string_id, :force => true, :id => false do |t|
+ t.string :id, :null => false
+ t.string :info
+ end
+
create_table :items, :force => true do |t|
t.column :name, :integer
end