Limits nested set overhead when destroying an issue without children.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@5286 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
6550ef9df5
commit
2c4cc25433
@ -444,11 +444,12 @@ module CollectiveIdea #:nodoc:
|
|||||||
# Prunes a branch off of the tree, shifting all of the elements on the right
|
# Prunes a branch off of the tree, shifting all of the elements on the right
|
||||||
# back to the left so the counts still work.
|
# back to the left so the counts still work.
|
||||||
def prune_from_tree
|
def prune_from_tree
|
||||||
return if right.nil? || left.nil? || !self.class.exists?(id)
|
return if right.nil? || left.nil? || leaf? || !self.class.exists?(id)
|
||||||
|
|
||||||
delete_method = acts_as_nested_set_options[:dependent] == :destroy ?
|
delete_method = acts_as_nested_set_options[:dependent] == :destroy ?
|
||||||
:destroy_all : :delete_all
|
:destroy_all : :delete_all
|
||||||
|
|
||||||
|
# TODO: should destroy children (not descendants) when deleted_method is :destroy_all
|
||||||
self.class.base_class.transaction do
|
self.class.base_class.transaction do
|
||||||
reload_nested_set
|
reload_nested_set
|
||||||
nested_set_scope.send(delete_method,
|
nested_set_scope.send(delete_method,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user