Commit 2ee87601 by John Hawthorn

Revert "raise error for acts_as_paranoid on models without primary keys"

This reverts commit 6881e750.
parent c32a7c6b
...@@ -154,7 +154,6 @@ end ...@@ -154,7 +154,6 @@ end
class ActiveRecord::Base class ActiveRecord::Base
def self.acts_as_paranoid(options={}) def self.acts_as_paranoid(options={})
raise "primary key required for "+self.name unless self.primary_key
alias :destroy! :destroy alias :destroy! :destroy
alias :delete! :delete alias :delete! :delete
def really_destroy! def really_destroy!
......
...@@ -28,7 +28,6 @@ def connect! ...@@ -28,7 +28,6 @@ def connect!
ActiveRecord::Base.connection.execute 'CREATE TABLE custom_column_models (id INTEGER NOT NULL PRIMARY KEY, destroyed_at DATETIME)' ActiveRecord::Base.connection.execute 'CREATE TABLE custom_column_models (id INTEGER NOT NULL PRIMARY KEY, destroyed_at DATETIME)'
ActiveRecord::Base.connection.execute 'CREATE TABLE custom_sentinel_models (id INTEGER NOT NULL PRIMARY KEY, deleted_at DATETIME NOT NULL)' ActiveRecord::Base.connection.execute 'CREATE TABLE custom_sentinel_models (id INTEGER NOT NULL PRIMARY KEY, deleted_at DATETIME NOT NULL)'
ActiveRecord::Base.connection.execute 'CREATE TABLE non_paranoid_models (id INTEGER NOT NULL PRIMARY KEY, parent_model_id INTEGER)' ActiveRecord::Base.connection.execute 'CREATE TABLE non_paranoid_models (id INTEGER NOT NULL PRIMARY KEY, parent_model_id INTEGER)'
ActiveRecord::Base.connection.execute 'CREATE TABLE idless_models (deleted_at DATETIME)'
end end
class WithDifferentConnection < ActiveRecord::Base class WithDifferentConnection < ActiveRecord::Base
...@@ -621,12 +620,6 @@ class ParanoiaTest < test_framework ...@@ -621,12 +620,6 @@ class ParanoiaTest < test_framework
assert_equal 3, parent.very_related_models.size assert_equal 3, parent.very_related_models.size
end end
def test_model_without_primary_key
assert_raises(RuntimeError) do
IdlessModel.class_eval{ acts_as_paranoid }
end
end
private private
def get_featureful_model def get_featureful_model
FeaturefulModel.new(:name => "not empty") FeaturefulModel.new(:name => "not empty")
...@@ -765,6 +758,3 @@ class AsplodeModel < ActiveRecord::Base ...@@ -765,6 +758,3 @@ class AsplodeModel < ActiveRecord::Base
raise StandardError, 'ASPLODE!' raise StandardError, 'ASPLODE!'
end end
end end
class IdlessModel < ActiveRecord::Base
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment