提交 cd64471b 编写于 作者: M Michael Koziarski

Fix calling .clear on a has_many :dependent=>:delete_all association. [tarmo] Closes #6904


git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7767 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
上级 5a276643
*SVN*
* Fix calling .clear on a has_many :dependent=>:delete_all association. [tarmo]
* Allow change_column to set NOT NULL in the PostgreSQL adapter [tarmo]
* Fix that ActiveRecord would create attribute methods and override custom attribute getters if the method is also defined in Kernel.methods. [Rick]
......
......@@ -67,7 +67,7 @@ def delete(*records)
def clear
return self if length.zero? # forces load_target if it hasn't happened already
if @reflection.options[:dependent] && @reflection.options[:dependent] == :delete_all
if @reflection.options[:dependent] && @reflection.options[:dependent] == :destroy
destroy_all
else
delete_all
......
......@@ -831,7 +831,8 @@ def test_clearing_an_exclusively_dependent_association_collection
assert_equal 0, firm.exclusively_dependent_clients_of_firm.size
assert_equal 0, firm.exclusively_dependent_clients_of_firm(true).size
assert_equal [3], Client.destroyed_client_ids[firm.id]
# no destroy-filters should have been called
assert_equal [], Client.destroyed_client_ids[firm.id]
# Should be destroyed since the association is exclusively dependent.
assert Client.find_by_id(client_id).nil?
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册