Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Change order of updates

The idea is to try to avoid having right < left, so that one can have a
CHECK(right_col > left_col) in the table. Doesn't yet work out fully.
  • Loading branch information...
commit da7d51acc672898ea5e99b9ab5b2394e68ce156d 1 parent 0b19544
@moritz authored
Showing with 9 additions and 9 deletions.
  1. +9 −9 lib/DBIx/Class/Tree/NestedSet.pm
View
18 lib/DBIx/Class/Tree/NestedSet.pm
@@ -365,16 +365,16 @@ sub _graft_branch {
# Make a hole in the tree to accept the graft
$self->discard_changes;
$rset->search({
- "me.$left" => {'>=', $arg_left},
+ "me.$right" => {'>=', $arg_left},
$root => $self->$root,
})->update({
- $left => \"$left + $offset", #"
+ $right => \"$right + $offset", #"
});
$rset->search({
- "me.$right" => {'>=', $arg_left},
+ "me.$left" => {'>=', $arg_left},
$root => $self->$root,
})->update({
- $right => \"$right + $offset", #"
+ $left => \"$left + $offset", #"
});
# make the graft
@@ -444,17 +444,17 @@ sub _move_to_end {
# Now move everything (except the root) back to fill in the gap
$offset = $self->$right + 1 - $self->$left;
$rset->search({
- "me.$left" => {'>=', $old_right},
+ "me.$right" => {'>=', $old_right},
+ $left => {'!=', 1}, # Root needs no adjustment
$root => $self->$root,
})->update({
- $left => \"$left - $offset", #"
+ $right => \"$right - $offset", #"
});
$rset->search({
- "me.$right" => {'>=', $old_right},
- $left => {'!=', 1}, # Root needs no adjustment
+ "me.$left" => {'>=', $old_right},
$root => $self->$root,
})->update({
- $right => \"$right - $offset", #"
+ $left => \"$left - $offset", #"
});
$self->discard_changes;
}
Please sign in to comment.
Something went wrong with that request. Please try again.