Subject: | Can't attach an independent root node |
When I create two independent nodes (ie root nodes), and I try to attach
one as the child of the other, I get the error message
Cannot _attach_node to it's own descendant
The attached patch fixes this.
Subject: | root_check.patch |
diff --git a/lib/DBIx/Class/Tree/NestedSet.pm b/lib/DBIx/Class/Tree/NestedSet.pm
index 55411ac..37218e7 100755
--- a/lib/DBIx/Class/Tree/NestedSet.pm
+++ b/lib/DBIx/Class/Tree/NestedSet.pm
@@ -298,7 +298,7 @@ sub _attach_node {
my ($root, $left, $right, $level) = $self->_get_columns;
# $self cannot be a descendant of $node or $node itself
- if ($self->$left >= $node->$left && $self->$right <= $node->$right) {
+ if ($self->$root == $node->$root && $self->$left >= $node->$left && $self->$right <= $node->$right) {
croak("Cannot _attach_node to it's own descendant ");
}