提交 57155064 编写于 作者: S schneems

Get update_attributes working with SchemaMigration

You cannot use `update_attributes` on models that do not have a primary key. Since SchemaMigration versions are guaranteed to be unique (they have a unique index on them) we can safely use them as a primary key.
上级 76c38570
......@@ -9,7 +9,7 @@ module ActiveRecord
class SchemaMigration < ActiveRecord::Base # :nodoc:
class << self
def primary_key
nil
"version"
end
def table_name
......
......@@ -21,10 +21,10 @@ class ActiveRecordSchemaTest < ActiveRecord::TestCase
ActiveRecord::Migration.verbose = @original_verbose
end
def test_has_no_primary_key
def test_has_has_primary_key
old_primary_key_prefix_type = ActiveRecord::Base.primary_key_prefix_type
ActiveRecord::Base.primary_key_prefix_type = :table_name_with_underscore
assert_nil ActiveRecord::SchemaMigration.primary_key
assert_equal "version", ActiveRecord::SchemaMigration.primary_key
ActiveRecord::SchemaMigration.create_table
assert_difference "ActiveRecord::SchemaMigration.count", 1 do
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册